gstat
gstat copied to clipboard
Error when using krigeST with separable spatio-temporal variogram when computing full covariance matrix
I am getting an error message when running krigeST with a separable spatio-temporal variogram when computing the full covariance matrix. Here is some reproducible code showing the error that I adapted from the krigeST example:
library(sp)
library(spacetime)
sumMetricVgm <- vgmST("separable",
space = vgm( 4.4, "Lin", 196.6, 3),
time = vgm( 2.2, "Lin", 1.1, 2),
# joint = vgm(34.6, "Exp", 136.6, 12),
sill = 1)
data(air)
suppressWarnings(proj4string(stations) <- CRS(proj4string(stations)))
rural = STFDF(stations, dates, data.frame(PM10 = as.vector(air)))
rr <- rural[,"2005-06-01/2005-06-03"]
rr <- as(rr,"STSDF")
x1 <- seq(from=6,to=15,by=1)
x2 <- seq(from=48,to=55,by=1)
DE_gridded <- SpatialPoints(cbind(rep(x1,length(x2)), rep(x2,each=length(x1))),
proj4string=CRS(proj4string(rr@sp)))
gridded(DE_gridded) <- TRUE
DE_pred <- STF(sp=as(DE_gridded,"SpatialPoints"), time=rr@time)
DE_kriged <- krigeST(PM10~1, data=rr, newdata=DE_pred,
modelList=sumMetricVgm,
computeVar = TRUE,
fullCovariance = TRUE)
gridded(DE_kriged@sp) <- TRUE
stplot(DE_kriged)
I chased down the problem, krigeST calls krigeST.df, which calls covfn.ST, which calls covSeparable, which needs to called with argument separate = FALSE. This argument is missing and set to false with the following lines of code
if (missing(separate))
separate <- inherits(x, "STF") & inherits(y, "STF") &
length(x) > 1 & length(y) > 1
as the argument x (and y) is of class "STSDF".