fit two sf polygons seamlessly fit two sf polygons seamlessly r r

fit two sf polygons seamlessly


ms_simplify seems to work on your minimal example but you need first to group your 2 "shapefiles" into one "shapefile". If needed it would be easy to split them after the simplification of the boundaries.
(note : my version of rmapshaper returns an error when ms_simplify is used with an sf object. This is why I have transformed my tmp object in a sp object with as(tmp, "Spatial"))

NEI <- st_transform(NEI, st_crs(REG)$epsg)tmp <- rbind(REG , NEI)tmp <- ms_simplify(as(tmp, "Spatial"), keep = .1, keep_shapes = T)ggplot() + geom_sf(data = st_as_sf(tmp)) + theme_bw()

enter image description here