我想要创建一个地理地图的加利福尼亚,也包括海峡群岛在R使用ggplot2 (而不是基础包)。当我用map_data来得到加州。它不包括海峡群岛。我怎样才能把这些岛屿放在地图上?似乎我可以使用raster提取2级数据,但我不知道如何合并这两个多边形,以获得一个包含状态和岛屿的地图?
library(maps) library(ggplot2)
states <- map_data("state")
CA <- subset(states, region %in% c("California"))
ggplot() + geom_polygon(data = CA, aes(x=long, y = lat)) + coord_fixed(1.3) + coord_sf(xlim = c(-125, -117.5), ylim = c(32.5, 39.5), expand = FALSE)
发布于 2022-10-27 21:32:29
{rnaturalearth}和相关的包包含岛屿信息,至少对于美国是这样的。
world <- rnaturalearth::ne_countries(scale = "medium", returnclass = "sf")
ggplot2::ggplot(data = world) +
ggplot2::geom_sf() +
ggplot2::coord_sf(
xlim = c(-127.15, -116.50),
ylim = c(31.90, 49.50),
expand = FALSE
)https://stackoverflow.com/questions/68036059
复制相似问题