lawn_within: Return points that fall within polygons

Description Usage Arguments Value See Also Examples

View source: R/within.R

Description

Takes a set of data-Point's and a set of data-Polygon's and returns points that fall within the polygons.

Usage

1
lawn_within(points, polygons, lint = FALSE)

Arguments

points

data-FeatureCollection of points.

polygons

data-FeatureCollection of polygons.

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

Points that land within at least one polygon, as a data-FeatureCollection.

See Also

Other joins: lawn_inside(), lawn_tag()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
cat(lawn_data$points_within)
cat(lawn_data$polygons_within)
lawn_within(lawn_data$points_within, lawn_data$polygons_within)

pt <- '{
 "type": "Feature",
 "properties": {},
 "geometry": {
    "type": "Point",
    "coordinates": [-90.548630, 14.616599]
  }
}'
poly <- lawn_featurecollection(lawn_buffer(pt, 5))
pts <- lawn_featurecollection(lawn_point(c(-90.55, 14.62)))

lawn_within(pts, poly)

## End(Not run)

Example output

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-46.6318, -23.5523]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-46.6246, -23.5325]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-46.6062, -23.5513]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-46.663, -23.554]
      }
    }, {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Point",
        "coordinates": [-46.643, -23.557]
      }
    }
    ]
}{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [[
          [-46.653,-23.543],
          [-46.634,-23.5346],
          [-46.613,-23.543],
          [-46.614,-23.559],
          [-46.631,-23.567],
          [-46.653,-23.560],
          [-46.653,-23.543]
          ]]
      }
    }
    ]
}<FeatureCollection>
  Bounding box: -46.6 -23.6 -46.6 -23.6
  No. features: 2
  No. points: 4
  Properties: NULL
<FeatureCollection>
  Bounding box: -90.5 14.6 -90.5 14.6
  No. features: 1
  No. points: 2
  Properties: NULL

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