lawn_inside: Does a point reside inside a polygon

View source: R/inside.R

lawn_insideR Documentation

Does a point reside inside a polygon

Description

Takes a data-Point and a data-Polygon or data-MultiPolygon and determines if the point resides inside the polygon

Usage

lawn_inside(point, polygon, lint = FALSE)

Arguments

point

Input point.

polygon

Input polygon or multipolygon.

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

Details

The polygon can be convex or concave. The function accounts for holes.

Value

TRUE if the Point IS inside the Polygon, FALSE if the Point IS NOT inside the Polygon.

See Also

Other joins: lawn_tag(), lawn_within()

Examples

point1 <- '{
  "type": "Feature",
  "properties": {
    "marker-color": "#f00"
  },
  "geometry": {
    "type": "Point",
    "coordinates": [-111.467285, 40.75766]
  }
}'
point2 <- '{
  "type": "Feature",
  "properties": {
    "marker-color": "#0f0"
  },
  "geometry": {
    "type": "Point",
    "coordinates": [-111.873779, 40.647303]
  }
}'
poly <- '{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-112.074279, 40.52215],
      [-112.074279, 40.853293],
      [-111.610107, 40.853293],
      [-111.610107, 40.52215],
      [-112.074279, 40.52215]
      ]]
  }
}'
lawn_inside(point1, poly)
lawn_inside(point2, poly)

ropensci/lawn documentation built on May 18, 2022, 9:58 a.m.