自动克里格和proj4string
我正在使用来自自动克里格和proj4string,r,spatial-interpolation,automap,R,Spatial Interpolation,Automap,我正在使用来自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=WGS8
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"
sp.poidf以下代码再现了您的问题:
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\u data=
(注意下划线)。以下代码运行良好:
kr = autoKrige(zinc~1, meuse, new_data = meuse.grid)
autoKrige
的文档显示了这一点,但是krige
(来自gstat)使用了newdata
,因此我理解这种混淆
问题在于,autoKrige
无法识别newdata=
,并将其放入参数列表的…
部分。当autoKrige
调用krige
时,由autoKrige
提供的new\u数据
与通过提供的newdata
之间存在冲突。为了防止其他用户最终收到相当模糊的错误消息,我在automap中添加了一个复选框。错误代码现在导致异常:
> 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'.
以下代码再现了您的问题:
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\u data=
(注意下划线)。以下代码运行良好:
kr = autoKrige(zinc~1, meuse, new_data = meuse.grid)
autoKrige
的文档显示了这一点,但是krige
(来自gstat)使用了newdata
,因此我理解这种混淆
问题在于,autoKrige
无法识别newdata=
,并将其放入参数列表的…
部分。当autoKrige
调用krige
时,由autoKrige
提供的new\u数据
与通过提供的newdata
之间存在冲突。为了防止其他用户最终收到相当模糊的错误消息,我在automap中添加了一个复选框。错误代码现在导致异常:
> 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'.
新版本很快就要发布了。有没有理由不使用被广泛接受的标准参数名称newdata
?不一致性无助于R的学习曲线。新版本将很快在CRAN上发布。有没有理由不使用广泛接受的标准参数名称newdata
?不一致性无助于R的学习曲线。