Remove features or portions of features that fall inside a specified area
Removes portions of the target layer that fall inside the erasing layer or bounding box.
ms_erase( target, erase = NULL, bbox = NULL, remove_slivers = FALSE, force_FC = TRUE, sys = FALSE )
target |
the target layer from which to remove portions. One of:
|
erase |
the erase layer (polygon). One of:
|
bbox |
supply a bounding box instead of an erasing layer to remove from
the target layer. Supply as a numeric vector: |
remove_slivers |
Remove tiny sliver polygons created by erasing. (Default |
force_FC |
should the output be forced to be a |
sys |
Should the system mapshaper be used instead of the bundled mapshaper? Gives better performance on large files. Requires the mapshaper node package to be installed and on the PATH. |
erased target in the same format as the input target
if (rmapshaper:::check_v8_major_version() >= 6L) { library(geojsonio, quietly = TRUE) library(sp) points <- structure("{\"type\":\"FeatureCollection\", \"features\":[{\"type\":\"Feature\",\"properties\":{}, \"geometry\":{\"type\":\"Point\",\"coordinates\": [52.8658,-44.7219]}},{\"type\":\"Feature\",\"properties\":{}, \"geometry\":{\"type\":\"Point\",\"coordinates\": [53.7702,-40.4873]}},{\"type\":\"Feature\",\"properties\":{}, \"geometry\":{\"type\":\"Point\",\"coordinates\":[55.3204,-37.5579]}}, {\"type\":\"Feature\",\"properties\":{},\"geometry\": {\"type\":\"Point\",\"coordinates\":[56.2757,-37.917]}}, {\"type\":\"Feature\",\"properties\":{},\"geometry\": {\"type\":\"Point\",\"coordinates\":[56.184,-40.6443]}}, {\"type\":\"Feature\",\"properties\":{},\"geometry\": {\"type\":\"Point\",\"coordinates\":[61.0835,-40.7529]}}, {\"type\":\"Feature\",\"properties\":{},\"geometry\": {\"type\":\"Point\",\"coordinates\":[58.0202,-43.634]}}]}", class = c("json", "geo_json")) points <- geojson_sp(points) plot(points) erase_poly <- structure('{ "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [ [ [51, -40], [55, -40], [55, -45], [51, -45], [51, -40] ] ] } }', class = c("json", "geo_json")) erase_poly <- geojson_sp(erase_poly) out <- ms_erase(points, erase_poly) plot(out, add = TRUE) }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.