Learn R Programming

lawn (version 0.1.7)

lawn_intersect: Intersection

Description

Finds the interesection of two data-Polygon's and returns just the intersection of the two

Usage

lawn_intersect(poly1, poly2, lint = FALSE)

Arguments

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

data-Polygon, data-MultiLineString, or undefined

Details

Polygons with just a shared boundary will return the boundary. Polygons that do not intersect will return NULL.

See Also

Other transformations: lawn_bezier, lawn_buffer, lawn_concave, lawn_convex, lawn_erase, lawn_merge, lawn_simplify, lawn_union

Examples

Run this code
poly1 <- '{
 "type": "Feature",
 "properties": {
   "fill": "#0f0"
 },
 "geometry": {
   "type": "Polygon",
   "coordinates": [[
     [-122.801742, 45.48565],
     [-122.801742, 45.60491],
     [-122.584762, 45.60491],
     [-122.584762, 45.48565],
     [-122.801742, 45.48565]
    ]]
 }
}'

poly2 <- '{
 "type": "Feature",
 "properties": {
   "fill": "#00f"
 },
 "geometry": {
   "type": "Polygon",
   "coordinates": [[
     [-122.520217, 45.535693],
     [-122.64038, 45.553967],
     [-122.720031, 45.526554],
     [-122.669906, 45.507309],
     [-122.723464, 45.446643],
     [-122.532577, 45.408574],
     [-122.487258, 45.477466],
     [-122.520217, 45.535693]
     ]]
 }
}'
lawn_intersect(poly1, poly2)

Run the code above in your browser using DataLab