Bivariate Spline Interpolation
stats-interpAkima.Rd
Interpolates bivariate data sets using Akima spline interpolation.
Arguments
- x, y, z
for
akimaInterp
the argumentsx
andy
are two numeric vectors of grid pounts, andz
is a numeric matrix or any other rectangular object which can be transformed by the functionas.matrix
into a matrix object. ForakimaInterpp
we consider either three numeric vectors of equal length or ify
andz
are NULL, a list with entriesx
,y
,z
, or named data frame withx
in the first,y
in the second, andz
in the third column.- gridPoints
an integer value specifying the number of grid points in
x
andy
direction.- xo, yo
for
akimaInterp
two numeric vectors of data points spanning the grid, and forakimaInterpp
two numeric vectors of data points building pairs for pointwise interpolation.- extrap
a logical, if
TRUE
then the data points are extrapolated.
Details
Two options are available: gridded and pointwise interpolation.
akimaInterp
is a wrapper to interp
provided by the
contributed R package akima
. The Fortran code of the Akima
spline interpolation routine was written by H. Akima.
Linear surface fitting and krige surface fitting are provided by the
functions linearInterp
and krigeInterp
.
Note
Package akima
is no longer needed. Equivalent functions from
package interp
are now called instead.
Value
- akimaInterp
returns a list with at least three entries,
x
,y
andz
. Note, that the returned values, can be directly used by thepersp
andcontour
3D plotting methods.- akimaInterpp
returns a data.frame with columns
"x"
,"y"
, and"z"
.
References
Akima H., 1978, A Method of Bivariate Interpolation and Smooth Surface Fitting for Irregularly Distributed Data Points, ACM Transactions on Mathematical Software 4, 149-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.
Examples
# \donttest{
## Does not run for r-solaris-x86
## akimaInterp -- Akima Interpolation:
if (requireNamespace("interp")) {
set.seed(1953)
x <- runif(999) - 0.5
y <- runif(999) - 0.5
z <- cos(2*pi*(x^2+y^2))
ans <- akimaInterp(x, y, z, gridPoints = 41, extrap = FALSE)
persp(ans, theta = -40, phi = 30, col = "steelblue",
xlab = "x", ylab = "y", zlab = "z")
contour(ans)
}
#> Loading required namespace: interp
## Use spatial as alternative on r-solaris-x86
## spatialInterp - Generate Kriged Grid Data:
if (requireNamespace("spatial")) {
RNGkind(kind = "Marsaglia-Multicarry", normal.kind = "Inversion")
set.seed(4711, kind = "Marsaglia-Multicarry")
x <- runif(999)-0.5
y <- runif(999)-0.5
z <- cos(2*pi*(x^2+y^2))
ans <- krigeInterp(x, y, z, extrap = FALSE)
persp(ans)
title(main = "Kriging")
contour(ans)
title(main = "Kriging")
}
#> Warning: RNGkind: Marsaglia-Multicarry has poor statistical properties
#> Warning: RNGkind: Marsaglia-Multicarry has poor statistical properties
# }