GRID_TPS

GRID_TPS

The GRID_TPS function uses thin plate splines to interpolate a set of values over a regular two dimensional grid, from irregularly sampled data values. Thin plate splines are ideal for modeling functions with complex local distortions, such as warping functions, which are too complex to be fit with polynomials.

Given n points, (xi, yi) in the plane, a thin plate spline can be defined as:

with the constraints:

where ri2 = (x-xi)2 + (y-yi)2. A thin plate spline (TPS) is a smooth function, which implies that it has continuous first partial derivatives. It also grows almost linearly when far away from the points (xi, yi). The TPS surface passes through the original points: f(xi, yi) = zi.

Note: GRID_TPS requires at least 7 noncolinear points.

Examples

The following example creates a set of 25 random values defining a surface on a square, 100 units on a side, starting at the origin. Then, we use GRID_TPS to create a regularly gridded surface, with dimensions of 101 by 101 over the square, which is then displayed. The same data set is then interpolated using TRIGRID, and the two results are displayed for comparison.

Syntax

Return Value

An array of dimension (nx, ny) of interpolated values. If the values argument is a two-dimensional array, the output array has dimensions (nz, nx, ny), where nz is the leading dimension of the values array allowing for the interpolation of arbitrarily sized vectors in a single call. Keywords can be used to specify the grid dimensions, size, and location.

Note: If the Cholesky factorization used within GRID_TPS fails, then Result will be a scalar 0.

Arguments

Xp

A vector of x points.

Yp

A vector of y points, with the same number of elements as the Xp argument.

Values

A vector or two-dimensional array of values to interpolate. If values are a two-dimensional array, the leading dimension is the number of values for which interpolation is performed.

Keywords

COEFFICIENTS

A named variable in which to store the resulting coefficients of the thin plate spline function for the last set of Values. The first N elements, where N is the number of input points, contain the coefficients bi, in the previous equation. Coefficients with subscripts n, n+1, and n+2, contain the values of a0, a1, and a2, in the above equation.

DELTA

A two-element array specifying the grid spacing in X and Y. If this keyword is not specified, or if one of the elements is set equal to zero, the grid spacing is determined from the values of the NGRID and START keywords, according to the following rules:

DELTA0 = (MAX(Xp) - START0)/(NGRID0 - 1)

DELTA1 = (MAX(Yp) - START1)/(NGRID1 - 1)

DELTA can also be set to a scalar value to be used for the grid size in both X and Y.

NGRID

A two-element array of the size of the grid to interpolate (nx, ny). If a scalar is passed, the value is used for both nx and ny. The default value is [25, 25].

START

A two-element array of the location of grid point (x0, y0). If a scalar is passed, the value is used for both x0 and y0. The default is the minimum values in the xp and yp arrays.