R 自动克里格和空间像素网格文件

R 自动克里格和空间像素网格文件,r,mapping,kriging,R,Mapping,Kriging,我正在尝试在automap包中使用autoKrige。 我的数据看起来像 head(LL12) Location Longitude Latitude percent 1 L1 16.48476 -28.60737 1.0000000 2 L3 16.90045 -29.24154 1.0000000 3 L4 16.99268 -28.44906 0.6363636 4 L5 17.06871 -29.67825 1.0000

我正在尝试在automap包中使用autoKrige。 我的数据看起来像

head(LL12)

  Location Longitude  Latitude   percent
1       L1  16.48476 -28.60737 1.0000000
2       L3  16.90045 -29.24154 1.0000000
3       L4  16.99268 -28.44906 0.6363636
4       L5  17.06871 -29.67825 1.0000000
5       L6  17.09935 -29.00169 0.6000000
6       L7  17.25630 -28.82418 1.0000000
我正试图在南非地图上画出这个

首先我得到了下面的网格

但是
plot(SAgrd\u pts\u in)
给出了以下错误信息:

.subset2(x,i,exact=exact)中的错误:下标超出范围

当我想在自动克里金中使用下面这行时,也会给出错误消息

krigLL12_fit <- autoKrige(percent~1, SA.grid, LL12spdf) # percent is the variable of interest in the spdf LL12spdf

krigLL12_-fit我发现了问题:网格文件需要将NA应用于其crs,然后将其转换为空间像素文件,而不是空间像素数据帧。
我对此进行了扩展,并在

我发现了问题:网格文件需要将NA应用于其crs,然后将其转换为空间像素文件,而不是空间像素数据帧。 我对此进行了扩展,并在

SAgrd_pts_in = as(SAgrd_pts_in,"SpatialPixelsDataFrame") 
krigLL12_fit <- autoKrige(percent~1, SA.grid, LL12spdf) # percent is the variable of interest in the spdf LL12spdf