[R] akima interpolation and triangulation question

steven wilson swpt07 at gmail.com
Thu May 29 06:03:19 CEST 2008


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



More information about the R-help mailing list