how to fix autoKrige.cv error?

244 Views Asked by At

can anyone please find the error in the r code (automap package) below, or give me some advice about auto cross-validation??

library(automap)
mydata<-read.table(".../mydata.txt", header=T, sep=",")
x<-mydata[,1]
y<-mydata[,2]
data1<-mydata[,3]
mydata.grid<-read.table(".../mydata.grid.txt", header=T, sep=",")
coordinates(mydata)=~x+y
gridded(mydata.grid)=~x+y
mykr.cv<-autoKrige.cv(log(data1)~1, mydata, model=c("Ste"), nfold=10)

But it shows this error:

0% Error: dimensions do not match: locations 120 and data 64

The spatial data I use hase 3 columns (x, y, mydata) for 64 points, and grids data in 2 columns (x, y) which contains 97868 points.

1

There are 1 best solutions below

1
On BEST ANSWER

After loading mydata.txt, try to rename the columns of your dataframe without instantiate new vectors:

colnames(mydata) = c("x","y","data1")

then:

coordinates(mydata)=~x+y
mykr.cv<-autoKrige.cv(log(data1)~1, mydata, model=c("Ste"), nfold=10)

I've tried to answer without a reproducible example of your dataset. Next time, please provide one.