I have a map of countries (sf object) and I would like to shift the longitude of the eastern portion of Russia so that it is not isolated from the rest of Russia. See Image
I found the backend code for st_shift_longitude https://github.com/r-spatial/sf/blob/master/R/shift_longitude.R, which shifts all coordinates by 180 degrees, so that the resulting map looks as follows:
link
How can I modify this block of code to shift the eastern portion of Russia only?
shift_lon <- function(x){
xcrs = st_crs(x)
g = (x + c(360, 90)) %% c(360) - c(0, 90)
st_wrap_dateline(st_set_crs(g - c(180, 0), xcrs)) + c(180, 0)
st_set_crs(g, xcrs)
}
st_geometry(countries) <- shift_lon(st_geometry(countries))
Alternative solutions are also welcome.
