Learn R Programming

lawn (version 0.1.7)

lawn_erase: Erase one polygon from another

Description

Finds the difference between two data-Polygon's by clipping the second polygon from the first.

Usage

lawn_erase(poly1, poly2, lint = FALSE)

Arguments

poly1
input Polygon feaure
poly2
Polygon feature to erase from poly1
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-Polygon feature showing the area of poly1 excluding the area of poly2

See Also

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

Examples

Run this code
poly1 <- '{
 "type": "Feature",
  "properties": {
    "fill": "#0f0"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-46.738586, -23.596711],
      [-46.738586, -23.458207],
      [-46.560058, -23.458207],
      [-46.560058, -23.596711],
      [-46.738586, -23.596711]
    ]]
  }
}'

poly2 <- '{
  "type": "Feature",
  "properties": {
    "fill": "#00f"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-46.650009, -23.631314],
      [-46.650009, -23.5237],
      [-46.509246, -23.5237],
      [-46.509246, -23.631314],
      [-46.650009, -23.631314]
    ]]
  }
}'
lawn_erase(poly1, poly2)

Run the code above in your browser using DataLab