[R-sig-Geo] performing IDW interpolations

Nerak nerak.t at hotmail.com
Thu Sep 13 15:23:50 CEST 2012


Hi! 
I'm still struggling with the IDW interpolation, because I want to try it on
my own example. I'm trying to work following the example from the book
'Applied spatial data analyses with R'. 

library(gstat) 
data(meuse) 
coordinates(meuse) <- c("x", "y") 
data(meuse.grid) 
coordinates(meuse.grid) <- c("x", "y") 
gridded(meuse.grid) <- TRUE 
idw.out <- idw(zinc ~ 1, meuse, meuse.grid, idp = 2.5) 
spplot(idw.out, "var1.pred")

(Little description of my goals: I have data from 14 raingauges and want to
interpolate the precipitation data between these points. Then I want to
collect the rastervalues of these for my sampling points (Have coordinates
for the points for which I want to know the precipitation). I did it in
qgis, but want to learn how to do it in R because it's daily rainfall data
and I need to do this for some years so would like to automize the process)
So I have the coordinates for my 14 point for which I have the data I want
to interpolate. This would be the locations including the data. My problem
is that I don't have grid data available in R. (I have some rasterdata from
the area, 3 band but don't know yet how to import this. Struggled for a
while to figure out how things as gdal are working but didn't succeed yet to
install and understand). Is there an easy way to produce this grid? I did
this interpolation in Quantum gis, wherefore only the coordinates and
raindata was enough to create the raster from which I could sample the point
values. I have the result from the interpolation in GIS as asc format so I
know the coordinates of the corners of that rectangular plane (Xmin = 
31.79410 Xmax=31.98010 Ymin=-21.24310 Ymax=-20.96710 reference
system=+proj=utm +zone=35 +south +datum=WGS84 +units=m +no_defs). But a grid
with these 4 points (vb spatialpixelsdataframe) is not enough I suppose? Is
there an easy way to make a grid that could be used?

(I tried to use thins like this to create a grid using the 4 coordinates:
zim.grid <- as(coor.zim, "SpatialPixelsDataFrame")
Error in validityMethod(object) : 
  data.frame is empty (possibly after stripping coordinate columns): use
SpatialPoints() to create points-only object        )


Many thank in advance for your help. I have experience in basic programming
in R and suppose this should be kind of basic spatial analysis, but I
experience it's really hard to learn it from a book (eventhough 'Applied
spatial data analyses with R' is a great book).
Kind regards,
Nerak


(I have a question concerning the habits and rules of this forum. Is it OK
to make a new topic for a new question, however it's related to a previous
question I asked some days ago? Now I created a new topic but when it's more
appreciated of I do it in the same topic, I'll do that next time)




--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/performing-IDW-interpolations-tp7580956.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list