Working with Irregularly Gridded Data
The IDL routines TRIANGULATE and TRIGRID allow you to fit irregularly sampled data to a regular grid, allowing you to visualize the values using IDL's surface and contour visualization routines. This example creates surface plots of some irregularly sampled data.
- First, we create a sample data set from some random values.
- Use the TRIANGULATE procedure to construct a Delaunay triangulation of our set of randomly-generated points:
- Use the TRIGRID function to create a regular grid of interpolated Z values, using the Delaunay triangulation:
- Display the interpolated surface values as wire-frame meshes side by side in the iSurface tool:
x = RANDOMU(seed, 32)
y = RANDOMU(seed, 32)
z = EXP(-3*((x-0.5)^2+(y-0.5)^2))(For more on IDL's random number generation, see RANDOMU.)
The variable tr now contains a three-dimensional array listing the triangles in the Delaunay triangulation of the points specified by the X and Y arguments.
grid_linear = TRIGRID(x, y, z, tr)
By default, the TRIGRID function uses linear interpolation. To use quintic interpolation, set the QUINTIC keyword:
grid_quintic = TRIGRID(x, y, z, tr, /QUINTIC)
ISURFACE, grid_linear, STYLE=1, VIEW_GRID=[2,1]
ISURFACE, grid_quintic, STYLE=1, /VIEW_NEXT
For more information, see the TRIANGULATE and TRIGRID topics in the IDL Online Help.
