我正在制作罗宾逊投影(即椭圆形)的世界Map,想通过将海洋的颜色设置为蓝色来区分海洋和陆地。如何在非矩形投影中做到这一点?
library("ggplot2")
library("sf")
library("rnaturalearth")
library("rnaturalearthdata")
world <- ne_countries(scale = "medium", returnclass = "sf")
# Creates map with land and ocean as color white
ggplot(data = world) +
geom_sf(color = "gray60", fill = "white") +
coord_sf(crs = "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs", expand = F) +
theme_bw() +
theme(panel.grid.major = element_line(color = 'gray75', linetype = "dashed", size = 0.25),
panel.border = element_blank(),
panel.background = element_blank())
# Creates map with a blue ocean however, the blue extends to a rectangle shape
# Would be ideal if the blue ocean fill was confined to the oval shape of the projection
ggplot(data = world) +
geom_sf(color = "gray60", fill = "white") +
coord_sf(crs = "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs", expand = F) +
theme_bw() +
theme(panel.grid.major = element_line(color = 'gray75', linetype = "dashed", size = 0.25),
panel.border = element_blank(),
panel.background = element_rect(fill = 'aliceblue'))
1条答案
按热度按时间gmol16391#
将海洋创建为多边形并首先对其进行绘图。