更新时间:2021-11-07 23:21:46
如果传递给 gstat:variogram
的数据对象是一个空间对象(你的数据是一个SpatialGridDataFrame
) 那么您不需要指定位置,因为这些位置包含在数据中.
If the data object passed to gstat:variogram
is a spatial object (your data is aSpatialGridDataFrame
) then you do not need to specify the locations, as these are contained in the data.
然而,很明显 NA
值引起了问题,所以如果我们强制网格对象是 SpatialPointsDataFrame
,这将删除 NA
代码>值
However, clearly the NA
values are causing a problem, so if we force the grid object to be a SpatialPointsDataFrame
, this will remove the NA
values
im
包含数据 https://gist.github.com/2780792一个>
library(gstat)
point_data <- as(im, 'SpatialPointsDataFrame')
gstat_variogram <- variogram(band1 ~ 1, data = point_data)
使用geoR
library(geoR)
geor_variogram <- variog(coords = coordinates(point_data),
data = point_data@data$band1)
或者更简单(作为 geoR
与 geodata
类的对象一起使用,并包含函数 as.geodata
以从 >SpatialPointsDataFrame
到 geodata
对象
or even more simply (as geoR
works with objects of class geodata
and contains the function as.geodata
to convert from a SpatialPointsDataFrame
to geodata
object
geor_variogram <- variog(as.geodata(point_data))