I would like to create on single polygon from multiple small polygons (see the image below which represents what I want)
I need to connect the polygons and I found that purrr::st_connect
might work but it seems we need two objects to connect but in my case all polygons are in the same object.
When I will have one object I will apply smoothr::smooth()
function that smooth the border of a polygon.
Can someone please tell me how I could connect polygons which are within the same object?
library(dplyr)
library(sf)
nc <- st_read(system.file("shape/nc.shp", package="sf"))
set.seed(2806)
nc_sample=dplyr::sample_n(nc,10)
ggplot() + geom_sf(data = nc_sample)
As suggested by Spacedman in the comment I could create buffers around my polygons, I connect them and i get the image below. But the thing is I would have to select a different distance for the buffer if I apply the code to states which are further away than those in this sample.
nc_buffer = st_buffer(nc_sample, 40000)
nc_poly=st_union(nc_buffer)
ggplot() +
geom_sf(data = nc_poly) +
geom_sf(data = nc_sample)