GenerateContourLines Task
This task generates contour lines from an input raster and converts them to a shapefile.
Example
This simple example plots contour lines at 1300, 1500, and 1700 meters in a digital elevation model (DEM).
; Start the application
e = ENVI()
; Open an input file
File = Filepath('bhdemsub.img', $
Subdir=['classic','data'], Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
; Get the task from the catalog of ENVITasks
Task = ENVITask('GenerateContourLines')
; Define inputs
Task.INPUT_RASTER = Raster
Task.LEVELS = [1300,1500,1700]
; Run the task
Task.Execute
; Get the collection of data objects currently
; available in the Data Manager
DataColl = e.Data
; Add the output to the Data Manager
DataColl.Add, Task.OUTPUT_VECTOR
; Display the result
View = e.GetView()
Layer = View.CreateLayer(Raster)
Layer2 = View.CreateLayer(Task.OUTPUT_VECTOR)
See More Examples.
Syntax
Result = ENVITask('GenerateContourLines')
Input parameters (Set, Get): INPUT_RASTER, LEVELS, MINIMUM_LENGTH, OUTPUT_VECTOR_URI
Output parameters (Get only): OUTPUT_VECTOR
Parameters marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Parameters marked as "Get" are those whose values you can retrieve but not set.
Input Parameters
INPUT_RASTER (required)
Specify a single-band raster from which to generate contour lines; for example, a DEM, gridded bathymetry data, or gridded magnetic anomaly data.
LEVELS (required)
Specify an array of data values to create create contours for. You can provide discrete values; for example, [100, 500, 750] to create contour lines at 100, 500, and 700 meters elevation. Or, use the GenerateIndexArray task to create an array of values as input to the LEVELS parameter. See the code example in the More Examples section.
MINIMUM_LENGTH (optional)
Specify the minimum contour length to be considered. Lines shorter than this value will be discarded. This parameter 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.
OUTPUT_VECTOR_URI (optional)
Specify a string with the fully qualified path and filename for OUTPUT_VECTOR.
Output Parameters
OUTPUT_VECTOR
This is a reference to the output vector.
Methods
Properties
More Examples
This example plots contour lines every 5 meters in a DEM. It uses the RasterStatistics task to get the minimum and maximum elevation values from a DEM. These are passed to the GenerateIndexArray task, which creates the array of values needed for the LEVELS parameter.
; Start the application
e = ENVI()
; Open an input file
File = Filepath('bhdemsub.img', $
Subdir=['classic','data'], Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
; Calculate image statistics
StatsTask = ENVITask('RasterStatistics')
StatsTask.INPUT_RASTER = Raster
StatsTask.Execute
minElevation = StatsTask.MIN
maxElevation = StatsTask.MAX
; Create an array of values every 10 meters
IndexTask = ENVITask('GenerateIndexArray')
IndexTask.MIN = minElevation
IndexTask.MAX = maxElevation
IndexTask.INCREMENT = 10
IndexTask.Execute
; Get the task from the catalog of ENVITasks
Task = ENVITask('GenerateContourLines')
; Define inputs
Task.INPUT_RASTER = Raster
Task.LEVELS = IndexTask.OUTPUT_ARRAY
; Define outputs
Task.OUTPUT_VECTOR_URI = e.GetTemporaryFilename('shp')
; Run the task
Task.Execute
; Get the collection of data objects currently
; available in the Data Manager
DataColl = e.Data
; Add the output to the Data Manager
DataColl.Add, Task.OUTPUT_VECTOR
; Display the result
View = e.GetView()
Layer = View.CreateLayer(Raster)
Layer2 = View.CreateLayer(Task.OUTPUT_VECTOR)
Version History
|
ENVI 5.5. 1 |
Introduced |