library(geojsonsf)
library(sf)
poly <- structure('{"type":"FeatureCollection",
"features":[
{"type":"Feature",
"properties":{"a": 1, "b": 2},
"geometry":{"type":"Polygon","coordinates":[[
[102,2],[102,3],[103,3],[103,2],[102,2]
]]}}
,{"type":"Feature",
"properties":{"a": 5, "b": 3},
"geometry":{"type":"Polygon","coordinates":[[
[100,0],[100,1],[101,1],[101,0],[100,0]
]]}}]}', class = c("geojson", "json"))
poly <- geojson_sf(poly)
plot(poly)
length(poly)
poly
# Dissolve the polygon
out <- ms_dissolve(poly)
plot(out)
length(out)
out
# Dissolve and summing columns
out <- ms_dissolve(poly, sum_fields = c("a", "b"))
plot(out)
out
Run the code above in your browser using DataLab