Moshood Agba Bakare
2014-Mar-06 17:07 UTC
[R] Interpolation grid with points outside data area- gstat
Dear All,
An interpolation grid of spacing 100m by 100m was created for irregular
space spatial data. The plot of the grid and sample data shows some grid
points outside the data area. I guess the predicted values of those points
outside the data area will not be reliable. How do I modify my R script so
that the grid can be created within the range of sample data.
Note: The x-y bounding box for the sample spatial data is
min max
easting 299678.9 301298.6
northing 5737285.6 5738128.1
while the x-y bounding box for the created interpolation grid is
min max
easting 299628 301328
northing 5737235 5738135
My R script is as follows:
# get the range of spatial coordinates in the data
easting.range <- as.integer(range(canmod.sp@coords[,1]))
northing.range <-as.integer(range(canmod.sp@coords[,2]))
## now expand to a grid with 100 meter spacing:
grd <- expand.grid(x=seq(from=easting.range[1], to=easting.range[2],
by=100),
y=seq(from=northing.range[1], to=northing.range[2], by=100))
names(grd)<-c("easting","northing")
coordinates(grd)<-~easting+northing
proj4string(grd)<-CRS("+proj=utm +zone=12 +ellps=WGS84 +datum=WGS84
+units=m +no_defs +towgs84=0,0,0")
## plot grid and sample data:
plot(grd, cex=0.2)
points(canmod.sp, pch=1,col="red", cex=0.4)
title("Interpolation Grid and Sample Points")
#### Ordinary kriging to create kriging prediction object
prok <- krige(id="yield",yield ~ 1, canmod.sp, newdata = grd,
model=exp.mod,block=c(10,10),nmax=100)
Your advice, comment and suggestion are highly welcome on what to do so
that grid points will be within the data area so that the predicted for
such points can be reliable.
Thanks
Moshood
[[alternative HTML version deleted]]