问题:跨越国际日期变更线的多边形经常有南北线穿过。rnaturalearth 包中的俄罗斯东部就是一个很好的例子,但我在其他空间数据中也遇到过这种情况。我希望能够删除这条线以进行绘图。
尝试: 我主要使用R中的sf包进行映射。我尝试了各种解决方案,包括 st_union、st_combine、st_wrap_dateline、st_remove_holes,以及使用其他包中的函数(例如aggregate、merge 和 gUnaryUnion),但到目前为止我的努力没有结果。
示例:以下代码使用流行的 rnaturalearth 包演示了俄罗斯沿国际日期变更线的问题线。
library(tidyverse)
library(rnaturalearth)
library(sf)
#Import data
world <- ne_countries(scale = "medium",
returnclass = "sf")
#I use the Alaska albers projection for this map,
#limit extent (https://spatialreference.org/ref/epsg/nad83-alaska-albers/)
xmin <- -2255938
xmax <- 1646517
ymin <- 449981
ymax <- 2676986
#plot
ggplot()+
geom_sf(data=world, color="black", size=1)+
coord_sf(crs=3338)+
xlim(c(xmin,xmax))+ylim(c(ymin,ymax))+
theme_bw()
Run Code Online (Sandbox Code Playgroud)
谢谢!
我试图在中央子午线不同于0的Robinson投影中投影世界地图。根据此StackOverFlow线程,这应该很容易(尽管示例使用sp)。
这是我的可复制代码:
library(sf)
library(ggplot2)
library(rnaturalearth)
world <- ne_countries(scale = 'small', returnclass = 'sf')
# Notice +lon_0=180 instead of 0
world_robinson <- st_transform(world, crs = '+proj=robin +lon_0=180 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')
ggplot() +
geom_sf(data = world_robinson)
Run Code Online (Sandbox Code Playgroud)
这就是结果。多边形从投影的一侧向另一侧闭合。

尝试具有sp相同的效果。我还尝试了一个shapefile,该文件仅包含来自http://www.naturalearthdata.com/的海岸线多边形(无政治边界),效果相似。

我试图在Mac OS X和Ubuntu 18.04上的两个独立的R安装上运行我的代码段。