[R-sig-Geo] Predicting TPS from fields onto SpatialPixelsDataFrame object
Andy Bunn
bunn@ @end|ng |rom wwu@edu
Fri Apr 24 18:36:15 CEST 2020
Hi all, I'm used to using gstat for kriging surfaces from either sp or sf and stars objects. E.g., following the workflow below using meuse and meuse.grid. I'm curious how I can use Tps in the fields library. Given the zincTPSModel object below, how can I predict it onto meuse.grid? Thanks in advance, A
library(sp)
library(gstat)
library(fields)
# set up data
data(meuse)
data(meuse.grid)
meuse$logZinc <- log(meuse$zinc)
coordinates(meuse) <- ~x+y
proj4string(meuse) <- CRS("+init=epsg:28992")
coordinates(meuse.grid) <- ~x+y
proj4string(meuse.grid) <- CRS("+init=epsg:28992")
meuse.grid <- as(meuse.grid,"SpatialPixelsDataFrame")
# kriging
zincVar <- variogram(logZinc~1, meuse)
zincVar <- variogram(logZinc~1, meuse)
zincModel <- vgm(psill=0.6, model="Sph", range=750, nugget=0.05)
zincFit <- fit.variogram(object = zincVar, model = zincModel)
plot(zincVar,model=zincModel,pch=20,cex=1.5,col="black",
ylab=expression("Semivariance ("*gamma*")"),
xlab="Distance (m)", main = "Zinc concentrations (log(ppm))")
zincKrige <- krige(formula = logZinc~1, locations = meuse,
newdata = meuse.grid, model = zincFit)
spplot(zincKrige,"var1.pred")
# thin plate spline
zincTPSModel <- Tps(coordinates(meuse), meuse$logZinc)
# predict onto meuse.grid?
More information about the R-sig-Geo
mailing list