lawn_count: Count number of points within polygons

Description Usage Arguments Value See Also Examples

View source: R/count.R

Description

Calculates the number of data-Point's that fall within the set of data-Polygon's

Usage

1
lawn_count(polygons, points, in_field, out_field = "count", lint = FALSE)

Arguments

polygons

a data-FeatureCollection of data-Polygon features

points

a data-FeatureCollection of data-Point features

in_field

(character) the field in input data to analyze

out_field

(character) the field in which to store results

lint

(logical) Lint or not. Uses geojsonhint. Takes up increasing time as the object to get linted increases in size, so probably use by default for small objects, but not for large if you know they are good geojson objects. Default: FALSE

Value

a data-FeatureCollection

See Also

Other aggregations: lawn_average(), lawn_collect(), lawn_deviation(), lawn_max(), lawn_median(), lawn_min(), lawn_sum(), lawn_variance()

Examples

1
2
3
4
5
6
7
## Not run: 
# using data in the package
cat(lawn_data$points_count)
cat(lawn_data$polygons_count)
lawn_count(lawn_data$polygons_count, lawn_data$points_count, 'population')

## End(Not run)

Example output

{
"type": "FeatureCollection",
"features": [
    {
      "type": "Feature",
      "properties": {
        "population": 200
      },
      "geometry": {
        "type": "Point",
        "coordinates": [-112.0372, 46.608058]
      }
    }, {
      "type": "Feature",
      "properties": {
        "population": 600
      },
      "geometry": {
        "type": "Point",
        "coordinates": [-112.045955, 46.596264]
      }
    }
    ]
}{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [[
          [-112.072391,46.586591],
          [-112.072391,46.61761],
          [-112.028102,46.61761],
          [-112.028102,46.586591],
          [-112.072391,46.586591]
          ]]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [[
          [-112.023983,46.570426],
          [-112.023983,46.615016],
          [-111.966133,46.615016],
          [-111.966133,46.570426],
          [-112.023983,46.570426]
          ]]
      }
    }
    ]
}<FeatureCollection>
  Bounding box: -112.1 46.6 -112.0 46.6
  No. features: 2
  No. points: 20
  Properties: 
    values count
1 200, 600     2
2              0

lawn documentation built on Jan. 6, 2021, 5:07 p.m.