Fint2d: 2-d Interpolation

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/Fint2d.R


Interpolate a function of two variables by rounding (i.e. taking the nearest value), bilinear or bicubic interpolation.


Fint2d(X, Ws, s, method = c("round", "bilinear", "bicubic"), derivs = FALSE, ...)



A numeric n by m matrix giving the value of the function at the old coordinates.


A numeric k by 2 matrix of new grid coordinates where k <= m * n.


A numeric k by 2 matrix of old grid coordinates where k <= m * n.


character naming one of “round” (default), “bilinear”, or “bicubic” giving the specific interpolation method to use.


logical, should the gradient interpolatants be returned?


Not used.


Method round simply returns the values at each grid point that correspond to the nearest points in the old grid.

Interpolation of a function, say H, is achieved by the following formula (cf. Gilleland et al 2010, sec. 3), where r and s represent the fractional part of their respective coordinate. that is, r = x - g( x ) and s = y - g( y ), where g( x ) is the greatest integer less than x.

sum_k sum_l b_k( r ) * b_l( s ) * H(g( x ) + l, g( y ) + k).

The specific choices for the values of b_l and b_k and their ranges depends on the type of interpolation. For bilinear interpolation, they both range from 0 to 1, and are given by: b_0( x ) = 1 - x and b_1( x ) = x. for bicubic interpolation, they both range from -1 to 2 and are given by:

b_-1( t ) = (2 * t^2 - t^3 - t) / 2

b_0( t ) = (3 * t^3 - 5 * t^2 + 2) / 2

b_1( t ) = (4 * t^2 - 3 * t^3 + t) / 2

b_2( t ) = ((t - 1) * t^2) / 2.


If deriv is FALSE, then a matrix is returned whose values correspond to the new coordinates. Otherwise a list is returned with components:


matrix whose values correspond to the new coordinates.

dx, dy

matrices giving the x and y direction gradients of the interpolation.


Eric Gilleland


Gilleland and co-authors (2010) Spatial forecast verification: Image warping. NCAR Technical Note, NCAR/TN-482+STR, DOI: 10.5065/D62805JJ.

See Also

rigider, rigidTransform


# see rigider for an example.

SpatialVx documentation built on March 28, 2021, 1:10 a.m.