2

I have several global map layers I am plotting using ggplot() + geom_sf() + etc. All data is "+proj=longlat +datum=WGS84 +no_defs". My goal is to have Eurasia be a contiguous land mass. This means having the prime meridian be at +12 as opposed to the default 0. An example with ocean data:

library(ggplot2)
library(sf)
library(rnaturalearth)
oceans <- ne_download(scale = 110, type = 'ocean', category = 'physical', returnclass = "sf")
ggplot() + geom_sf(data=oceans)

Map of oceans from rnaturalearth

#check CRS
st_crs(oceans)$proj4string 
[1] "+proj=longlat +datum=WGS84 +no_defs"

#st_transform with pm at 12 so Eurasia is one blob
oceans2 <- st_transform(oceans,  crs = "+proj=longlat +datum=WGS84 +pm=12 +no_defs")
ggplot() + geom_sf(data=oceans2)

#check CRS
st_crs(oceans2)$proj4string 
[1] "+proj=longlat +ellps=WGS84 +pm=12 +no_defs"
#unclear on why this is not "+proj=longlat +datum=WGS84 +pm=12 +no_defs"

Map of shifted oceans from rnaturalearth

I am unclear how to remove the white and black lines (vertical and horizontal) shown in the shifted image.

3
  • That black border in the first image, which gets transformed into a mess on the second one, is an artefact of you plotting the oceans, in order to create complete polygons for filling in ocean colours. Do you need the oceans as polygons or are you going to be plotting onto the land on this map?
    – Spacedman
    Commented May 23, 2022 at 11:42
  • I will start with a land-based map (geom_stars right now) and then add coastlines, lakes and oceans.
    – rps
    Commented May 23, 2022 at 13:54
  • I should note that there is a narrow scope where this is easily achievable: library(ggplot2) library(dplyr) shift_value_1 <- -168 shift_value_2 <- 192 shift_value_2 - shift_value_1 #must be 360 map0 <- map_data('world', wrap=c(shift_value_1, shift_value_2)) %>% dplyr::filter(region != "Antarctica") ggplot() + geom_polygon(data = map0, aes(x=long, y = lat, group = group), fill = "gainsboro", color = "gainsboro", size = 0.15)
    – rps
    Commented May 24, 2022 at 12:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.