Learn R Programming

akima (version 0.6-3.4)

bicubic.grid: Bicubic Interpolation for Data on a Rectangular grid

Description

The description in the Fortran code says:

This subroutine performs interpolation of a bivariate function, z(x,y), on a rectangular grid in the x-y plane. It is based on the revised Akima method.

In this subroutine, the interpolating function is a piecewise function composed of a set of bicubic (bivariate third-degree) polynomials, each applicable to a rectangle of the input grid in the x-y plane. Each polynomial is determined locally.

This subroutine has the accuracy of a bicubic polynomial, i.e., it interpolates accurately when all data points lie on a surface of a bicubic polynomial.

The grid lines can be unevenly spaced.

Usage

bicubic.grid(x,y,z,xlim=c(min(x),max(x)),ylim=c(min(y),max(y)),
             nx=40,ny=40,dx=NULL,dy=NULL)

Arguments

x

a vector containing the x coordinates of the rectangular data grid.

y

a vector containing the y coordinates of the rectangular data grid.

z

a matrix containing the z[i,j] data values for the grid points (x[i],y[j]).

xlim

vector of length 2 giving lower and upper limit for range x coordinates used for output grid.

ylim

vector of length 2 giving lower and upper limit for range of y coordinates used for output grid.

nx

output grid dimension in x direction.

ny

output grid dimension in y direction.

dx

output grid spacing in x direction, not used by default, overrides nx if specified.

dy

output grid spacing in y direction, not used by default, overrides ny if specified..

Value

This function produces a grid of interpolated points, feasible to be used directly with image and contour:

x

vector of x coordinates of the output grid.

y

vector of y coordinates of the output grid.

z

matrix of interpolated data for the output grid.

Details

This functiuon is a R interface to Akima's Rectangular-Grid-Data Fitting algorithm (TOMS 760). The algorithm has the accuracy of a bicubic (bivariate third-degree) polynomial.

References

Akima, H. (1996) Rectangular-Grid-Data Surface Fitting that Has the Accuracy of a Bicubic Polynomial, J. ACM 22(3), 357-361

See Also

interp, bicubic

Examples

Run this code
# NOT RUN {
data(akima760)
# interpolate at a grid [0,8]x[0,10]
akima.bic <- bicubic.grid(akima760$x,akima760$y,akima760$z)
zmin <- min(akima.bic$z, na.rm=TRUE)
zmax <- max(akima.bic$z, na.rm=TRUE)
breaks <- pretty(c(zmin,zmax),10)
colors <- heat.colors(length(breaks)-1)
image(akima.bic, breaks=breaks, col=colors)
contour(akima.bic, levels=breaks,  add=TRUE)
# }

Run the code above in your browser using DataLab