Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.

Harris Geospatial / Docs Center / Using IDL / Surface with Contour Lines


Surface with Contour Lines

Surface with Contour Lines

You can enhance surface graphics by overplotting contour data to show more detail. In this topic, we will show two examples of using the SURFACE function along with the CONTOUR to display gravity and elevation data.

For an additional example using SURFACE, see Plot 3D Terrain and Water Table.

Example 1

For this example, we display simulated data for gravity measurements from a hypothetical meteorite impact crater in New South Wales, Australia. The data is stored in the file 'CraterGravityMeasurements.csv' in your IDL Examples/Data directory.

Since this is ungridded CSV data, read it in with your choice of ASCII readers. In this example we use READ_ASCII() with ASCII_TEMPLATE(). We will then grid the data before creating SURFACE and CONTOUR plots.

; Create the base template and assign X, Y, and Z as the variable names.
; Make sure to start the data at row 2 (row 1 contains column headers).
myTemplate = ASCII_TEMPLATE()
; Read in the data.
grav = READ_ASCII('CraterGravityMeasurements.csv', TEMPLATE=myTemplate)
; Grid the data to 1 meter using the Kriging method (set DIMENSION to 1000
; since the data covers 1000 meters squared). Optionally, to reduce rendering time
; change DIMENSION to 100 (gridding to 10 meter squares).
grid = GRIDDATA(grav.x, grav.y, grav.z, DIMENSION=1000, METHOD="Kriging")
; Create the surface plot from the gridded data. Note that if you set
; DIMENSION to 100 in the previous step, change the X and Y titles to
; "Meters (x 10)".
mySurf = SURFACE(grid, RGB_TABLE=16, TRANSPARENCY=25, COLOR='burlywood', $
   XTITLE="Meters", YTITLE="METERS", TITLE="Gravity Measurements at Impact Crater, NSW Australia")
; Create an alternate z-axis at the back of the plot for easier reading.
; Note that if you set DIMENSION to 100, use LOCATION=[0,105] here.
zAxis = AXIS('Z', LOCATION=[0, 1010], TITLE='Measured Gravity (mGal)', $
   TICKINTERVAL=0.5, AXIS_RANGE=[-2.0,0.0])
; Do not display the original z-axis.
; Finally, add the gridded contours.
contours = CONTOUR(grid, C_VALUE=grav.z, PLANAR=0, /OVERPLOT)

Example 2

This example works with digital elevation data from the Maroon Bells Wilderness in Colorado, USA.

The code shown below creates the graphic shown above. You can copy the entire block and paste it into the IDL command line to run it.

  ; Define the elevation data to use.
  RESTORE, FILEPATH('marbells.dat', $
     SUBDIRECTORY=['examples', 'data'])
  ; Display the elevation surface.
  mySurface = SURFACE(elev, TITLE='Maroon Bells Elevation Data')
  ; Overlay the contour data.
  myContour = CONTOUR(elev, N_LEVELS=15, $

Note: The ZVALUE keyword will not have any visual effect unless PLANAR is set to 0 and the plot is in a 3D dataspace, such as in conjunction with the SURFACE function.


© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us