Convert multipart lines or polygons to singlepart
For objects of class Spatial
(e.g., SpatialPolygonsDataFrame
),
you may find it faster to use sp::disaggregate
.
ms_explode(input, force_FC = TRUE, sys = FALSE)
input |
One of:
|
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. |
There is currently no method for SpatialMultiPoints
same class as input
library(geojsonio) library(sp) poly <- structure("{\"type\":\"FeatureCollection\",\"crs\": {\"type\":\"name\",\"properties\":{\"name\": \"urn:ogc:def:crs:OGC:1.3:CRS84\"}},\"features\": [\n{\"type\":\"Feature\",\"geometry\":{\"type\": \"MultiPolygon\",\"coordinates\":[[[[102,2],[102,3], [103,3],[103,2],[102,2]]],[[[100,0],[100,1],[101,1], [101,0],[100,0]]]]},\"properties\":{\"rmapshaperid\":0}}\n]}", class = c("json", "geo_json")) poly <- geojson_sp(poly) plot(poly) length(poly) poly@data # Explode the polygon out <- ms_explode(poly) plot(out) length(out) out@data
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.