lawn_difference: Difference

Description Usage Arguments Value See Also Examples

View source: R/erase.R

Description

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

Usage

1
lawn_difference(poly1, poly2, lint = FALSE)

Arguments

poly1

A data-Feature<(data-Polygon)> feature

poly2

data-Feature<(data-Polygon)> 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-Feature<(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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
## Not run: 
# skipping on cran
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_difference(poly1, poly2)

## End(Not run)
## Not run: 
lawn_featurecollection(list(poly1, poly2)) %>% view
lawn_difference(poly1, poly2) %>% view
fc <- lawn_featurecollection(list(
   lawn_polygon(jsonlite::fromJSON(poly1)$geometry$coordinates),
   lawn_polygon(jsonlite::fromJSON(poly2)$geometry$coordinates)
))
view(fc)

## End(Not run)

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