Use the Generate Contour Lines tool to create a shapefile of contour lines from a full-resolution input raster.

You can write a script to generate full-resolution contour lines using the GenerateContourLines task.

Follow these steps:

  1. From the ENVI Toolbox, select Terrain > Generate Contour Lines. The Generate Contour Lines dialog appears.
  2. Select an Input Raster such as a digital elevation model (DEM) or any dataset where you want to categorize the data with contour lines.
  3. In the Levels field, enter an array of values from which to create contour lines. For example, an array of [5, 10, 15, 20] in a georeferenced DEM will create contour lines every 5, 10, 15, and 20 units.
  4. Instead of manually entering the values, you can click the Define Values button . The Generate Index Array dialog appears. Specify any combination of the following values to automatically create an array for Levels:

    • Number of Elements: Optional. Indicate the number of elements in the resulting array.
    • Minimum Value: Optional. Indicate the minimum value of the array.
    • Maximum Value: Optional. Indicate the maximum value of the array.
    • Increment: Optional. Indicate the desired increment between consecutive values.
    • Set the Reverse radio button to Yes to reverse the order of the output elements. The default selection is No.

    Click OK in the Generate Index Array dialog.

    See Examples of Contour Levels below.

    To save the Levels array to a JSON-format file on disk, click the Save Values button and select a filename and location for the output file (.json).

    To restore an array of values from disk, click the Open Values button and select a .json file.

  5. In the Minimum Length field, specify the minimum contour length to be considered. Lines shorter than this value will be discarded. This property is not set by default, which means that all contours will be included in the output. The units depend on the coordinate system of the input raster.
  6. In the Output Vector field, specify a path and filename for the output shapefile of contour lines.
  7. Enable the Preview check box to see a preview of the settings before you click OK to process the data. The preview is calculated only on the area in the view and uses the resolution level at which you are viewing the image. See Preview for details on the results. To preview a different area in your image, pan and zoom to the area of interest and re-enable the Preview option.
  8. Enable the Display result check box to display the output in the view when processing is complete. Otherwise, if the check box is disabled, the result can be loaded from the Data Manager.
  9. To reuse these task settings in future ENVI sessions, save them to a file. Click the down arrow and select Save Parameter Values, then specify the location and filename to save to. Note that some parameter types, such as rasters, vectors, and ROIs, will not be saved with the file. To apply the saved task settings, click the down arrow and select Restore Parameter Values, then select the file where you previously stored your settings.

  10. To run the process in the background, click the down arrow and select Run Task in the Background. If an ENVI Server has been set up on the network, the Run Task on remote ENVI Server name is also available. The ENVI Server Job Console will show the progress of the job and will provide a link to display the result when processing is complete. See ENVI Servers for more information.

  11. Click OK.

Examples of Contour Levels


Example 1:

  • Number of Elements: Not set
  • Minimum Value: 10
  • Maximum Value: 20
  • Increment: 3
  • Reverse: No
  • Resulting array: [10, 13, 16, 19]

Example 2:

  • Number of Elements: 4
  • Minimum Value: Not set
  • Maximum Value: 150
  • Increment: 10
  • Reverse: No
  • Resulting array: [120, 130, 140, 150]

Example 3:

  • Number of Elements: 25
  • Minimum Value: 20
  • Maximum Value: Not set
  • Increment: 5
  • Reverse: No
  • Resulting array: [20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140]

Example 4:

  • Number of Elements: 12
  • Minimum Value: Not set
  • Maximum Value: 0
  • Increment: -0.25
  • Reverse: No
  • Resulting array: [0,-0.25,-0.5,-0.75,-1,-1.25,-1.5,-1.75,-2,-2.25,-2.5,-2.75]
  • Setting the Increment to a positive value and setting the Reverse option to Yes will produce the same result.

See Also


Overlay Contour Lines