akima interpolation + Delaunay triangulation
In answering Steven I forgot to address this list also, so here is a repost of my answer (see below). At closing the R session in Emacs/ESS I got this:
Save workspace image? [y/n/c]: n
*** SDTRAN Error 2: The first three data points are collinear.
Error detected in SDTRAN called by SDSF3P
*** SDTRAN Error 2: The first three data points are collinear.
Error detected in SDTRAN called by SDSF3P
*** SDTRAN Error 2: The first three data points are collinear.
Error detected in SDTRAN called by SDSF3P
Process R finished at Wed Jun 04 11:05:28 2008
For this reason I have included the maintainer in the list. It support my answer.
My answer to Steven:
I think that it is because you data allready is gridded.
See ?interp where it is mentioned in the section on arguments:
'x', 'y', and 'z' must be the same length and may contain no
fewer than four points. The points of 'x' and 'y' cannot be
collinear, i.e, they cannot fall on the same line (two
vectors 'x' and 'y' such that 'y = ax + b' for some 'a', 'b'
will not be accepted). 'interp' is meant for cases in which
you have 'x', 'y' values scattered over a plane and a 'z'
value for each. If, instead, you are trying to evaluate a
mathematical function, or get a graphical interpretation of
relationships that can be described by a polynomial, try
'outer()'.
Try:
par(mfrow=c(2,1))
plot(u,v)
plot(jitter(u),jitter(v))
soil.interp3 <- interp(jitter(u),jitter(v),moist, linear=FALSE)
plot.surface(soil.interp3)
Best regards
Frede Aakmann T?gersen
Scientist
UNIVERSITY OF AARHUS
Faculty of Agricultural Sciences
Dept. of Genetics and Biotechnology
Blichers All? 20, P.O. BOX 50
DK-8830 Tjele
Phone: +45 8999 1900
Direct: +45 8999 1878
E-mail: FredeA.Togersen at agrsci.dk
Web: http://www.agrsci.org
This email may contain information that is confidential.
Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed.
If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email.
-----Oprindelig meddelelse-----
Fra: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch] P? vegne af steven wilson
Sendt: 3. juni 2008 5:55
Til: r-sig-geo at stat.math.ethz.ch
Emne: [R-sig-Geo] akima interpolation + Delaunay triangulation
Dear all;
I would like to have some input from anybody who have used
the interpolation function (interp) in the akima package and
the triangulation function (tri.mesh) from the tripack
pakage. My problem is that for a given data set these
functions return errors in R while in S-Plus they don't. The
versions of these functions in S-Plus
(S+SpatialStats) can be slightly different to those in R but
the output shoould be the same or approx the same because
they're based on the same algorithm and fortran code.
Here is the code in R:
library(akima)
library(fields)
library(tripack)
soil <-
read.table("http://www.unc.edu/~zhuz/teaching/Stat890/Data/soi
l.txt",header=TRUE)
attach(soil)
soil.interp <- interp(u, v, moist) # linear interpolation
works and the results are similar to those in S-Plus
plot.surface(soil.interp)
# spline interpolation
soil.interp2 <- interp(u, v, moist, linear = F) # spline
interpolation returns only NA's in R while using S-Plus it works fine
# triangulation
tri.mesh(soil$u, soil$v) # error in R, works in S-Plus
Any comments will be appreciated
Thanks
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo