I am using the R function autokrige from automap package, but I got an error and I do not know how to solve it. Do you have any hints?
Thank you!
sp.poidf <- SpatialPointsDataFrame(sp.poi,thresh.df)
proj4string(sp.poidf) <- CRS("+proj=longlat +datum=WGS84")
pro.df=spTransform(sp.poidf, CRS("+proj=merc +zone=32s +datum=WGS84"))
sp.new <- SpatialPoints(new.poi)
proj4string(sp.new) <- CRS("+proj=longlat +datum=WGS84")
pro.new <- spTransform(sp.new, CRS("+proj=merc +zone=32s +datum=WGS84"))
mykri <- autoKrige(mythresh~1,pro.df,newdata=pro.new)
Error in function (classes, fdef, mtable) :
unable to find an inherited method for function "proj4string", for signature "NULL"
The following code reproduces your problem:
The problem is that you use
newdata =, while you should be usingnew_data =(note the underscore). The following code runs fine:The documentation of
autoKrigeshows this, butkrige(from gstat) usesnewdata, so I understand the confusion.What goes wrong is that
newdata =is not recognized byautoKrige, and put in the...part of the argument list. WhenautoKrigecallskrigethere is a conflict betweennew_datasupplied byautoKrige, andnewdatasupplied via.... To prevent other users from ending up with the rather vague error message, I added a check to automap. The erroneous code now leads to an exception: