Dear all;
First of all, this is probably a more conceptual question than a
R-related one, but still want to give it a try. When working with the
interpolation function "interp" from the package akima and the
triangulation function "tri.mesh" from package tripack I've got
NA's
for the interpolation and "error" for the triangulation. The data is
arranged in a regular grid as opposed to what the help page for interp
says but I think this is an interesting problem because I found this
code on the web as part of an stats course (and it is not the only
example I found). Because I'm not really into the details of the
functions I would like to hear comments from people who have used
these functions before.
This is the code
library(akima)
library(fields)
library(tripack)
soil <-
read.table("http://www.unc.edu/~zhuz/teaching/Stat890/Data/soil.txt",header=TRUE)
attach(soil)
soil.interp <- interp(u, v, moist) # linear interpolation works
plot.surface(soil.interp)
# spline interpolation
soil.interp2 <- interp(u, v, moist, linear = F) # spline interpolation
returns only NA's
# triangulation
tri.mesh(soil$u, soil$v) # got error
Thanks
Prof Brian Ripley
2008-May-29 08:34 UTC
[R] akima interpolation and triangulation question
You have repeated (u,v) values in your data frame. It is not possible to interpolate such data, and I get an error from 'interp' (not NAs). *** SDTRAN Error 2: The first three data points are collinear. There is no problem with interpolating from a regular grid, but be aware that the triangulation-based methods are not isotropic in such a case (as the triangulation is not unique). R-sig-geo would be a more appropriate list for such questions. On Thu, 29 May 2008, steven wilson wrote:> Dear all; > > First of all, this is probably a more conceptual question than a > R-related one, but still want to give it a try. When working with the > interpolation function "interp" from the package akima and the > triangulation function "tri.mesh" from package tripack I've got NA's > for the interpolation and "error" for the triangulation. The data is > arranged in a regular grid as opposed to what the help page for interp > says but I think this is an interesting problem because I found this > code on the web as part of an stats course (and it is not the only > example I found). Because I'm not really into the details of the > functions I would like to hear comments from people who have used > these functions before. > > This is the code > > library(akima) > library(fields) > library(tripack) > > soil <- read.table("http://www.unc.edu/~zhuz/teaching/Stat890/Data/soil.txt",header=TRUE) > attach(soil) > soil.interp <- interp(u, v, moist) # linear interpolation works > plot.surface(soil.interp) > > # spline interpolation > soil.interp2 <- interp(u, v, moist, linear = F) # spline interpolation > returns only NA's > > # triangulation > tri.mesh(soil$u, soil$v) # got error > > Thanks > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595