This offers a basic method for dividing a shape into separate pieces
regionalize(shp, lines, adj = adjacency(shp), epsg = 3857)
sf
tibble to estimate regions for
sf
tibble which divides shp
into regions
adjacency graph
numeric EPSG code to planarize to. Default is 3857.
integer vector of regions with nrow(shp)
entries
data(towns)
# make some weird roadlike feature passing through the towns
lines <- sf::st_sfc(sf::st_linestring(sf::st_coordinates(sf::st_centroid(towns))),
crs = sf::st_crs(towns)
)
#> Warning: st_centroid assumes attributes are constant over geometries
regionalize(towns, lines)
#> [1] 1 2 1 1 2 2 2