Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

interpp.old

Pointwise Bivariate Interpolation for Irregular Data


Description

If 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.

Usage

interpp.old(x, y, z, xo, yo, ncp = 0, extrap = FALSE,
                    duplicate = "error", dupfun = NULL)
interpp.new(x, y, z, xo, yo, extrap = FALSE,
                    duplicate = "error", dupfun = NULL)

Arguments

x

vector of x-coordinates of data points or a SpatialPointsDataFrame object. Missing values are not accepted.

y

vector of y-coordinates of data points. Missing values are not accepted.

If left as NULL indicates that x should be a SpatialPointsDataFrame and z names the variable of interest in this dataframe.

z

vector of z-coordinates of data points or a character variable naming the variable of interest in the SpatialPointsDataFrame x.

Missing values are not accepted.

x, y, and z must be the same length (execpt if x is a SpatialPointsDataFrame) 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).

xo

vector of x-coordinates of points at which to evaluate the interpolating function. If x is a SpatialPointsDataFrame this has also to be a SpatialPointsDataFrame.

yo

vector of y-coordinates of points at which to evaluate the interpolating function.

If operating on SpatialPointsDataFrames this is left as NULL

ncp

deprecated, use parameter linear. 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 0 (partial derivatives are not used, = linear interpolation), or at least 2 but smaller than the number of data points (and smaller than 25).

extrap

logical flag: should extrapolation be used outside of the convex hull determined by the data points?

duplicate

indicates how to handle duplicate data points. Possible values are "error" - produces an error message, "strip" - remove duplicate z values, "mean","median","user" - calculate mean , median or user defined function of duplicate z values.

dupfun

this function is applied to duplicate points if duplicate="user"

Value

list with 3 components:

x

vector of x-coordinates of output points, the same as the input argument xo.

y

vector of y-coordinates of output points, the same as the input argument yo.

z

fitted z-values. The value z[i] is computed at the x,y point x[i], y[i].

If input is SpatialPointsDataFrame than an according SpatialPointsDataFrame is returned.

NOTE

Use interp if interpolation on a regular grid is wanted.

The two versions interpp.old and interpp.new are now deprecated, use interpp instead, see details there.

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.

References

Akima, H. (1978). A Method of Bivariate Interpolation and Smooth Surface Fitting for Irregularly Distributed Data Points. ACM Transactions on Mathematical Software, 4, 148-164.

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.

See Also


akima

Interpolation of Irregularly and Regularly Spaced Data

v0.6-2.1
ACM | file LICENSE
Authors
Hiroshi Akima [aut, cph] (Fortran code (TOMS 760, 761, 697 and 433)), Albrecht Gebhardt [aut, cre, cph] (R port (interp* functions), bicubic* functions), Thomas Petzold [ctb, cph] (aspline function), Martin Maechler [ctb, cph] (interp2xyz function + enhancements), YYYY Association for Computing Machinery, Inc. [cph] (covers code from TOMS 760, 761, 697 and 433)
Initial release
2016-12-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.