[R-sig-Geo] Masking interpolations
Wesley Roberts
wroberts at csir.co.za
Mon Feb 16 07:49:51 CET 2009
Dear R-sig-geo'ers
I am currently running some interpolations using automap written by Paul Hiemstra. So far my interpolations have been producing suitable results except for one problem. From the code you will see that the boundaries of the spatial grid are determined using the range of the X and Y coordinates creating a square grid. My point data do not cover the entire grid and I would only like to interpolate in areas where data exists otherwise I get a significant edge effect. Is it possible to limit / mask my interpolation to only predict where data exists?
The point data are lidar canopy returns for an irregular shaped timber compartment and number around 10 000 irregular spaced points.
Any help on this matter would be greatly appreciated.
Kind regards,
Wesley
library(automap)
library(gstat)
a <- read.csv("AreaOne_4pts.csv", header=TRUE)
coordinates(a) <-~ x+y
x.range <- as.integer(range(a at coords[,1]))
y.range <- as.integer(range(a at coords[,2]))
grd <- expand.grid(x=seq(from=x.range[1], to=x.range[2], by=0.1), y=seq(from=y.range[1], to=y.range[2], by=0.1))
coordinates(grd) <-~ x+y
gridded(grd) <- TRUE
height = autoKrige(H~1, a, grd, nmax=100)
writeGDAL(height$krige_output, fname="test.tiff", drivername ="GTiff", type = "Float32")
intensity = autoKrige(I~1, a, grd, nmax=100)
writeGDAL(intensity$krige_output, fname="test.tiff", drivername ="GTiff", type = "Float32")
Wesley Roberts MSc.
Researcher: Earth Observation (Ecosystems)
Natural Resources and the Environment
CSIR
Tel: +27 (21) 888-2490
Fax: +27 (21) 888-2693
"To know the road ahead, ask those coming back."
- Chinese proverb
--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard.
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.
This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean. MailScanner thanks Transtec Computers for their support.
More information about the R-sig-Geo
mailing list