library(geojsonsf)
library(sf)
poly <- "{\"type\":\"FeatureCollection\",\"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\":{\"a\":0}}\n]}"
poly <- geojson_sf(poly)
plot(poly)
length(poly)
poly
# Explode the polygon
out <- ms_explode(poly)
plot(out)
length(out)
out
Run the code above in your browser using DataLab