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.

isurface_irreg_gridded.gif

  1. First, we create a sample data set from some random values.
  2. Use the TRIANGULATE procedure to construct a Delaunay triangulation of our set of randomly-generated points:
  3. TRIANGULATE, x, y, tr

    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.

  4. Use the TRIGRID function to create a regular grid of interpolated Z values, using the Delaunay triangulation:
  5. 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)

  6. Display the interpolated surface values as wire-frame meshes side by side in the iSurface tool:
  7. 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.