[R-sig-Geo] DEM interpolation with Delaunay triangulation

Nagle, Nicholas nnagle at utk.edu
Wed Nov 23 14:15:32 CET 2011


For the first part of your question, interpolation:  I've never used it, but the 'tripack' package seems to do most of what you want.  There is a function tri.find() that returns the three points of the TIN.  From there, a linear interpolation shouldn't be too difficult.

For the second part, regarding the raster to polygons: I'm not sure exactly what you want, and I don't see how this task is related to the first part (a TIN isn't a raster), but assuming you have a raster.... there is a function rasterToPolygons() in the raster package that does this.  It is really really slow though.  It takes hours to do what can be done in 15 seconds in ArcGIS or GRASS.  

For using GRASS, in pseudo R-code, the workflow looks something like this

library(spgrass6)
initGRASS("/Applications/GRASS-6.4.app/Contents/MacOS/",home=tempdir(),override=TRUE) #For a Mac, obviously
writeRAST6(your.raster,'yourRaster',useGDAL=TRUE,overwrite=TRUE,flags='o')
execGRASS('r.to.vect',parameters=list(input='yourRaster',output='yourVect',feature='area'),flags=c('overwrite'))
execGRASS('v.clean', ...) # You'll have to experiment with this....
poly <- readVECT6('yourVect',layer='1')

I've had problems before with self-intersecting polygons when the polygon data come back to R, so the method isn't bulletproof.  Maybe someone else will have advice.

If any of this works, let us now!

Nicholas


> ------------------------------
> 
> Message: 11
> Date: Wed, 23 Nov 2011 09:36:06 +0100
> From: Edzer Pebesma <edzer.pebesma at uni-muenster.de>
> To: r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] DEM interpolation with Delaunay triangulation
> Message-ID: <4ECCB076.9010805 at uni-muenster.de>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> 
> 
> On 11/20/2011 11:02 PM, Rolf Turner wrote:
>> On 21/11/11 04:30, gianni lavaredo wrote:
>>> Dear Researchers,
>>> 
>>> I am looking a package o method to interpolate a point data.frame (x,y,z)
>>> with Delaunay triangulation  (Trianguled interpoaltion network) and
>>> create
>>> a polygons data,frame o a raster. I know there are several fuction in
>>> library RSAGA, spatstat (with "deldir"), library geometry.
>> 
>> I have no idea what you're on about.  If you could make your question
>> clearer and more specific I might be able to make some suggestions
>> as to how you could use spatstat/deldir.
>> 
>> An explicit simple (toy) example might help.
> 
> I have wondered this myself too -- the issue is the so-called TIN,
> triangular interpolation network. Say, we have (field) observations
> (x,y,z), we form a delanay triangulation on all (x,y) pairs, and we want
> to obtain the prediction of z for an arbitrary (x0,y0) pair, based on
> the linear trend surface fit through the three (x1,y1), (x2,y2), (x3,y3)
> points that form the triangle in which (x0,y0) falls.
> 
> You could do, of course, a linear trend surface using three nearest
> neighbours, e.g. by
> 
> require(gstat)
> loadMeuse()
> x = krige(log(zinc)~x+y, meuse, meuse.grid, nmax=3)
> spplot(x[1],col.regions=bpy.colors(),
> 	sp.layout=list("sp.points", meuse))
> 
> 
> but that takes the three nearest observations, which don't need to be
> the three points in the triangle (and often, they are not, because
> meuse.grid contains points outside the convex hull of the meuse
> observation locations).
> 
>> 
>>    cheers,
>> 
>>        Rolf Turner
>> 
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 
> -- 
> Edzer Pebesma
> Institute for Geoinformatics (ifgi), University of M?nster
> Weseler Stra?e 253, 48151 M?nster, Germany. Phone: +49 251
> 8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
> http://www.52north.org/geostatistics      e.pebesma at wwu.de
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 
> 
> End of R-sig-Geo Digest, Vol 99, Issue 22
> *****************************************
> 



More information about the R-sig-Geo mailing list