r - 使用命令 over() 时收到错误消息
问题描述
我有两个形状文件,shp1
和shp2
. 在计算了前者的质心后,我想看看质心在后者的位置。
我的设置是:
shp1@data$centroid <- gCentroid(shp1, byid = TRUE)
foo <- over(shp1$centroid, shp2)
执行第二行后,我收到以下错误消息:
Error in xj[i] : NAs not permitted in row index
知道我应该寻找什么来避免这个错误吗?(注意:grep("NA", row.names(shp1))
返回integer(0)
,也适用于其他形状文件。)
解决方案
刚刚弄清楚为什么会发生此错误:
除此之外shp1@data$centroid <- gCentroid(shp1, byid = TRUE)
,我shp2@data$centroid <- gCentroid(shp2, byid = TRUE)
在调用之前也做过foo <- over(shp1$centroid, shp2)
,这显然导致了错误。
推荐阅读
- mysql - 缺少数据库连接 cakephp
- laravel - 在 laravel 5.7 中显示数据透视表中的数据
- oracle - Oracle 12,已弃用 utl_dbws
- javascript - 使用其他脚本后 Javascript 脚本不运行
- java - 计算 20 名工人平均工资的 Java 程序
- python - 根据 df1 中的 3 个值匹配 df2 中的 3 个值填充数据框中的新列
- powershell - Powershell 函数返回值已更改
- swift - 如何在 iOS 中使用通用链接打开内部页面
- ios12 - Siri 快捷方式:“与 Siri 一起使用”未显示在设置中。不允许使用 Siri
- python - Windows python多处理:运行该函数时没有发生任何事情