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

问题描述 投票:1回答:1

我正在努力帮助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创建

r ggplot2 sf
1个回答
0
投票

[通常,使用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创建

© www.soinside.com 2019 - 2024. All rights reserved.