我正在使用automap包中的R函数autokrige,但是我得到了一个错误,我不知道如何解决它。你有什么提示吗?
谢谢!
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"发布于 2012-08-30 13:28:07
下面的代码重现了您的问题:
require(automap)
require(rgdal)
loadMeuse()
proj4string(meuse) = CRS("+init=epsg:28992")
proj4string(meuse.grid) = CRS("+init=epsg:28992")
meuse = spTransform(meuse, CRS("+proj=merc +zone=32s +datum=WGS84"))
# Note that meuse.grid no longer is a grid due to the reprojection
meuse.grid = spTransform(meuse.grid, CRS("+proj=merc +zone=32s +datum=WGS84"))
kr = autoKrige(zinc~1, meuse, newdata = meuse.grid)
Error in function (classes, fdef, mtable) :
unable to find an inherited method for function "proj4string", for signature "NULL"问题是你使用newdata =,而你应该使用new_data = (注意下划线)。下面的代码运行正常:
kr = autoKrige(zinc~1, meuse, new_data = meuse.grid)autoKrige的文档显示了这一点,但是krige (来自gstat)使用newdata,所以我理解其中的混淆。
错误之处在于autoKrige不能识别newdata =,并将其放入参数列表的...部分。当autoKrige调用krige时,autoKrige提供的new_data和通过...提供的newdata之间存在冲突。为了防止其他用户最终收到相当模糊的错误消息,我在自动映射中添加了一个检查。错误的代码现在会导致异常:
> kr = autoKrige(zinc~1, meuse, newdata = meuse.grid)
Error in autoKrige(zinc ~ 1, meuse, newdata = meuse.grid) :
The argument name for the prediction object is not 'newdata', but 'new_data'.https://stackoverflow.com/questions/12187045
复制相似问题