为什么我使用 ggplot2(R 映射)会出现节点堆栈溢出错误?

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

我第一次在 R 上创建地图,我尝试提取这个数据库,创建一个子集并用 ggplot 绘制它,但它给了我这个错误:

错误:节点堆栈溢出 另外:有 50 个或更多警告(使用 warnings() 查看前 50 个) 总结期间出错:节点堆栈溢出 错误:没有更多可用的错误处理程序(递归错误?);调用“中止”重新启动

这是脚本:

library(tidyverse)
library(geodata)
library(terra)
library(tidyterra)
library(ggplot2)

IT2 <- gadm(country = "ITA", level=2, path = tempdir())

unique(IT2[["NAME_1"]])

NW = subset(IT2,IT2$NAME_1=="Liguria" | IT2$NAME_1=="Piemonte"| IT2$NAME_1=="Valle d'Aosta", c("NAME_1", "NAME_2")) 

ggplot() + 
  geom_spatvector(data = NW, fill = NA, col = "black") +
  theme_void()

应该创建一个意大利三个地区的简单地图,但我得到的只是一个空白屏幕和报告的错误。

我尝试重新安装所有必须的库、重新启动 PC 和 RStudio、释放 RAM、清理环境,但我找不到解决方案。 这是一个非常简单的过程,NW 是一个只有 13 行和 2 列的空间向量,你认为问题是什么?

提前致谢!

r ggplot2 mapping runtime-error
1个回答
0
投票

无论是在下载形状文件还是创建新形状文件时,我总是遇到同样的问题:

library(terra)
library(tidyterra)
library(ggplot2)

GER <- geodata::gadm(country=c("Germany"),level=0,path=tempdir())

ggplot(GER) + geom_spatvector()

或:

library(terra)
library(tidyterra)
library(ggplot2)

points <- data.frame(GridID = c(1,2,3,4,5,6), Lat = c(53.8900,53.8900,53.8900,53.8900,53.8900,53.9125), Long = c(14.2425,14.2875,14.3325,14.3775,14.4225,11.2275))
grids <- terra::vect(x = points, geom = c("Long","Lat"), crs = "+proj=longlat +datum=WGS84 +no_defs +type=crs")
ggplot(grids) + geom_spatvector()

错误:节点堆栈溢出另外:有 50 个或更多警告 (使用 warnings() 查看前 50 个) 总结期间错误:节点堆栈 溢出错误:没有更多可用的错误处理程序(递归错误?); 调用“中止”重新启动

如果我尝试将 ggplot 存储在变量中,我会收到额外的警告:

g1 <- ggplot(grids) + geom_spatvector()

在 CPL_crs_from_input(x) 中:GDAL 错误 1:项目: proj_create_from_database:C:\程序 文件\PostgreSQL\shar

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