sf + ggplot 试图绘制斐济群岛地图

sf + ggplot trying to map Fiji Islands

我正在努力帮助一位 R 用户解决这个问题。我写了一个 sf+ ggplot 教程 (https://www.r-spatial.org//r/2018/10/25/ggplot2-sf),我正试图帮助别人弄清楚如何正确绘制斐济群岛。我一直在尝试操纵 xlim 和 ylim,但它没有正确环绕世界(因为坐标非常接近“0”)来显示所有岛屿。如果有人对解决此问题的方法有任何见解,将不胜感激,我可以将代码添加到教程中以备将来使用。谢谢!

library("ggplot2")
library("rnaturalearth")
library("rnaturalearthdata")

world <- ne_countries(scale = "medium", returnclass = "sf")

ggplot(data=world) +
  geom_sf() +
  coord_sf(xlim= c(175, 180), ylim=c(-20,-12.0), expand = TRUE)

reprex package (v0.3.0)

创建于 2019-11-02

通常,在使用 geom_sf() 时,您应该始终指定适当的坐标参考系统 (CRS)。这将制作出更好的地图,并且还将解决诸如您遇到的问题。在这种特定情况下,由于您想绘制斐济,您应该使用斐济特定的 CRS,例如这个:https://epsg.io/3460

coord_sf()调用中的绘图限制取自同一网站上可用的投影范围。

library("ggplot2")
library("rnaturalearth")
library("rnaturalearthdata")

world <- ne_countries(scale = "medium", returnclass = "sf")

ggplot(data=world) +
  geom_sf() + 
  coord_sf(
    crs = 3460, # https://epsg.io/3460
    xlim = c(1798028.61, 2337149.40), # limits are taken from projected bounds
    ylim = c(3577110.39, 4504717.19)  # of EPSG:3460
  )

reprex package (v0.3.0)

于 2019-11-02 创建