使用命令over()时收到错误消息

时间:2019-10-12 18:10:36

标签: r shapefile centroid rgeo-shapefile

我有两个形状文件,#include <stdint.h> typedef union { int32_t i; float f; } uSpec; void do_pow2(uint64_t *in_array, uint64_t *out_array, int num_loops) { uSpec u; for (int i=0; i<num_loops; i++) { int32_t x = *(int32_t *)&in_array[i]; u.i = (127 + x) << 23; int32_t r = (int32_t) u.f; out_array[i] = r; } } 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))。)

1 个答案:

答案 0 :(得分:0)

只需弄清楚为什么会发生此错误:

除了shp1@data$centroid <- gCentroid(shp1, byid = TRUE)外,我在调用shp2@data$centroid <- gCentroid(shp2, byid = TRUE)之前也做了foo <- over(shp1$centroid, shp2),这显然引起了错误。