在来自 rnaturalearth 的地图中裁剪和绘制矩形不再起作用
Crop and Plot a rectangle in a map from rnaturalearth does not work anymore
以下代码:
library(rnaturalearth,rnaturalearthdata)
library("sf")
#load world map and crop the rectangle I want
blank2 <- ne_countries(scale = "large",type = 'countries', returnclass = "sf")
blank1 <- st_crop(blank2 , xmin = -22, xmax = 44, ymin = 30, ymax = 66)
# plot map
plot(st_geometry(blank1),col="gray85",lty=0)
几周前还在绘制矩形地图。现在,它绘制了一种圆柱形图:
map of Europe which is not rectangular any more
好像默认投影在某个阶段发生了变化,但我没有找到在哪里,原则上一切都是 WGS84。
plot 函数改变了什么,或者 sf 包,或者 rnaturalearth 包?
我在 windows 机器上使用带有更新包的 R 4.0.4。
感谢您的帮助!
问题来了是因为sf包改变了它的默认几何结构。添加命令:sf_use_s2(FALSE) 允许返回到其原始行为。
以下代码:
library(rnaturalearth,rnaturalearthdata)
library("sf")
#load world map and crop the rectangle I want
blank2 <- ne_countries(scale = "large",type = 'countries', returnclass = "sf")
blank1 <- st_crop(blank2 , xmin = -22, xmax = 44, ymin = 30, ymax = 66)
# plot map
plot(st_geometry(blank1),col="gray85",lty=0)
几周前还在绘制矩形地图。现在,它绘制了一种圆柱形图: map of Europe which is not rectangular any more
好像默认投影在某个阶段发生了变化,但我没有找到在哪里,原则上一切都是 WGS84。
plot 函数改变了什么,或者 sf 包,或者 rnaturalearth 包?
我在 windows 机器上使用带有更新包的 R 4.0.4。
感谢您的帮助!
问题来了是因为sf包改变了它的默认几何结构。添加命令:sf_use_s2(FALSE) 允许返回到其原始行为。