[R] interpolating climate data
Mintewab Bezabih
Mintewab.Bezabih at economics.gu.se
Wed May 9 15:17:31 CEST 2012
Dear R-users,
I am working on interpolating the station level temperature data to farm level data. I have z vector consisting of station level temperature observations and my x and y are latitude and longitude corresponding to a farm. My understanding is I can use raster combined with tps. While I am clear with the tps bit, I am not sure how I can construct the raster with teh data I have. Here is the reproducable example I made
Many thanks in advance
regards,
Mintewab
library(fields)
x <-1:20
y<- runif(20)
z<- c(11, 15, 17, 2, 18, 6, 7, NA, 12, 10,21, 25, 27, 12, 28, 16,
17, NA, 12, 10)
mydataset<-data.frame(z, y, z)
mydataset[complete.cases(mydataset),]
tpsfit <- Tps(cbind(x, y), z, scale.type="unscaled")
library(raster)
r <- raster(system.file("external/test.grd", package="raster"))
p <- raster(r)
p <- interpolate(p, tpsfit)
p <- mask(p, r)
plot(p)
se <- interpolate(p, tpsfit, fun=predict.se)
se <- mask(se, r)
plot(se)
More information about the R-help
mailing list