ncp
is zero, linear
interpolation is used in the triangles bounded by data points.
Cubic interpolation is done if partial derivatives are used.
If extrap
is FALSE
, z-values for points outside the convex hull are
returned as NA
.
No extrapolation can be performed if ncp
is zero.
The interpp
function handles duplicate (x,y)
points in different ways. As default it will stop with an error message. But
it can give duplicate points an unique z
value according to the
parameter duplicate
(mean
,median
or any other user defined function).
The triangulation scheme used by interp
works well if x
and y
have
similar scales but will appear stretched if they have very different
scales. The spreads of x
and y
must be within four orders of magnitude
of each other for interpp
to work.interpp(x, y, z, xo, yo, linear=TRUE, extrap=FALSE, duplicate = "error",
dupfun = NULL, ncp)
x
, y
, and z
must be the same length and may contain no fewer
than four points. The points of x
and y
ncp
parameterlinear
. Now only used by
interpp.old()
. meaning was:
number of additional points to be used in computing partial
derivatives at each data point.
ncp
must be either
"error"
- produces an error message, "strip"
- remove
duplicate z values, "mean"
,"median"
,"user"
-
calculate mean ,duplicate="user"
xo
.yo
.z[i]
is computed
at the x,y point x[i], y[i]
.interp
if interpolation on a regular grid is wanted. The two versions interpp.old
and interpp.new
refer to
Akimas Fortran code from 1978 and 1996 resp. The call wrapper interpp
chooses interpp.old
for linear and interpp.new
for cubic
spline interpolation.
Earlier versions (pre 0.5-1) of interpp
used the parameter
ncp
to choose between linear and cubic interpolation, this is now done
by setting the logical parameter linear
. Use of ncp
is still
possible, but is deprecated.
Akima, H. (1996). Algorithm 761: scattered-data surface fitting that has the accuracy of a cubic polynomial. ACM Transactions on Mathematical Software, 22, 362-371.
contour
, image
,
approxfun
, splinefun
,
outer
, expand.grid
,
interp
, aspline
.data(akima)
# linear interpolation at points (1,2), (5,6) and (10,12)
akima.lip<-interpp(akima$x, akima$y, akima$z,c(1,5,10),c(2,6,12))
akima.lip$z
# spline interpolation
akima.sip<-interpp(akima$x, akima$y, akima$z,c(1,5,10),c(2,6,12),
linear=FALSE)
akima.sip$z
Run the code above in your browser using DataLab