Shapefile 未正确填充 geom_polygon,与 QGIS/ArcMap 不一致

Shapefile not filling properly with geom_polygon, inconsistent with QGIS/ArcMap

我已经通过 readOGR 从 Natural Earth 将世界海洋的 shapefile 导入到 R。当我尝试在 ggplot 中渲染它时,它填满了北美洲和南美洲的土地。该行为与 QGIS 和 ArcMap 不一致,两者都可以很好地渲染和填充 shapefile。有什么想法吗?

download.file("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/physical/ne_50m_ocean.zip" , destfile="./ne_50m_ocean.zip")
system("unzip ./ne_50m_ocean.zip")
wrld <- readOGR(dsn=getwd(),layer="ne_50m_ocean")
wrld <- tidy(wrld)
ggplot() + geom_polygon(data = wrld, aes(x = long, y = lat, group = group), colour = "black", fill = "blue")

screenshot of RStudio render

screenshot of QGIS render

我能够使用 read_sf() 而不是 readOGR() 解决这个问题,然后调整 ggplot 代码以适应。也适用于我的工作流程的下一部分,其中涉及使用 fasterize() 对 sf 对象进行栅格化以用于遮罩海洋层(包含简化的演示代码以防对其他人有用):

#get data
download.file("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/physical/ne_50m_ocean.zip" , destfile="./ne_50m_ocean.zip")
system("unzip ./ne_50m_ocean.zip")
wrld <- read_sf(dsn=getwd(),layer="ne_50m_ocean")

#plot sf object
ggplot() + geom_sf(data=wrld, colour = "black", fill = "blue")

#rasterize sf object
r <- raster(ncol=720, nrow=360) 
extent(r) <- extent(wrld) 
rp <- fasterize(wrld, r)
ocean <- as.data.frame(rasterToPoints(rp))

#plot raster object
ggplot() + geom_tile(data=ocean,aes(x=x,y=y),fill="white")