I'm trying to generate a coastline buffer by using
st_buffer() with data from the
rnaturalearth library. However, when I create the buffer, it extends outside the realm of the projection, rather than wrapping around to to the other "side." This creates problems for downstream shape use. Other coastline buffer problems (e.g. 1, 2) on GIS SE have not involved issues of projection edges or not been in R.
library(rgdal) library(rnaturalearth) library(sf) library(ggplot2) robin = CRS("+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs") ROI = ne_countries(returnclass = 'sf') %>% st_combine() %>% st_transform(robin) coastalWaters = ROI %>% st_buffer(500000) ggplot() + geom_sf(data = coastalWaters, fill = "lightblue", col = "transparent") + geom_sf(data = ROI)
The reproducible code above leads to a plot that looks like this (red circles annotated by me):
So, my question is, how can I buffer a global set of polygons with an "understood" wrapping? Solutions will preferably use the sf library of functions.