Given data points defined by the parameters X, Y, and Z and a triangulation of the planar set of points determined by X and Y , the TRIGRID function returns a regular grid of interpolated Z values. Linear or smooth quintic polynomial interpolation can be selected. Extrapolation for gridpoints outside of the triangulation area is also an option. The resulting grid is a two-dimensional array of the same data type as Z , with user-specified bounds and spacing. An input triangulation can be constructed using the procedure TRIANGULATE. Together, the TRIANGULATE procedure and the TRIGRID function constitute IDL's solution to the problem of irregularly-gridded data, including spherical gridding.
Input arrays of X, Y, and Z coordinates of data points. Integer, long, double-precision and floating-point values are allowed. In addition, Z can be a complex array. All three arrays must have the same number of elements.
A longword array of the form output by TRIANGULATE. That is,
has the dimensions (3, Number-of-Triangles) and, for each
are the indices of the vertices of the
If present, GS should be a two-element vector [ XS, YS ], where XS is the horizontal spacing between grid points and YS is the vertical spacing. The default is based on the extents of X and Y . If the grid starts at X value x 0 and ends at x 1 ,then the horizontal spacing is
If the NX or NY keywords are set to specify the output grid dimensions, either or both of the values of GS may be set to 0. In this case, the grid spacing is computed as the respective range divided by the dimension minus one:
If present, Limits should be a four-element vector [ x 0 , y 0 , x 1 , y 1 ] that specifies the data range to be gridded ( x 0 and y 0 are the lower X and Y data limits, and x 1 and y 1 are the upper limits). The default for Limits is:
If the NX or NY keywords are not specified, the size of the grid produced is specified by the value of Limits . If the NX or NY keywords are set to specify the output grid dimensions, a grid of the specified size will be used regardless of the value of Limits .
Set this keyword equal to an array of boundary node indices (as returned by the optional parameter B of the TRIANGULATE procedure) to extrapolate to grid points outside the triangulation. The extrapolation is not smooth, but should give acceptable results in most cases.
Set this keyword to a named variable (which must be an array of the appropriate size to hold the output from TRIGRID) in which the results of the gridding are returned. This keyword is provided to make it easy and memory-efficient to perform multiple calls to TRIGRID. The interpolates within each triangle overwrite the array and the array is not initialized.
NOTE: Letting MISSING default to 0 does not always produce the same result as explicitly setting it to 0. For example, if you specify INPUT and not EXTRAPOLATE, letting MISSING default to 0 will result in the INPUT values being used for data outside the Traingles; explicitly setting MISSSING to 0 will result in 0 being used for the data outside the Triangles.
If QUINTIC is set, smooth interpolation is performed using Akima's quintic polynomials from "A Method of Bivariate Interpolation and Smooth Surface Fitting for Irregularly Distributed Data Points" in ACM Transactions on Mathematical Software , 4, 148-159. The default method is linear interpolation.
The first example creates and displays a 50 point random normal distribution. The random points are then triangulated, with the triangulation displayed. Next, the interpolated surface is computed and displayed using linear and quintic interpolation. Finally, the smooth extrapolated surface is generated and shown.
[0,0], [0,0,5,4],NX=20, NY=40) ; Output size is 20 x 40. The range of the grid in X and Y is specified by the Limits parameter. Grid spacing in X is [5-0]/(20-1) = 0.263. Grid spacing in Y is (4-0)/(40-1) = 0.128.