I'm trying to merge groups of adjacent polygons, but I'm getting big multipolygons with non-adjacent areas. In the code block below plot(Matsuyama.sf)
shows a large contiguous region and a few islands, but I can't extract those geometries. How do I get those areas and geometries.
library(sf)
library(tidyverse)
Matsuyama.sf <- st_read("https://geoshape.ex.nii.ac.jp/city/geojson/20210101/38/38201A1968.geojson")
Matsuyama.sf <- st_transform(Matsuyama.sf, crs=4326)
plot(Matsuyama.sf)
st_area(Matsuyama.sf)
I can split into hundreds of polygons, but the code options below just lump them back together into one
split.sf <- st_cast(Matsuyama.sf, "POLYGON")
clumps_1.sf <- st_join(split.sf, split.sf, join = st_intersects)
clumps_2sf <- Matsuyama.sf %>% mutate(INTERSECT = st_intersects(.))
What am I missing?