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).
e = ENVI()
File = Filepath('bhdemsub.img', $
Subdir=['classic','data'], Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
Task = ENVITask('GenerateContourLines')
Task.INPUT_RASTER = Raster
Task.LEVELS = [1300,1500,1700]
Task.Execute
DataColl = e.Data
DataColl.Add, Task.OUTPUT_VECTOR
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
Execute
Parameter
ParameterNames
Properties
DESCRIPTION
DISPLAY_NAME
NAME
REVISION
TAGS
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.
e = ENVI()
File = Filepath('bhdemsub.img', $
Subdir=['classic','data'], Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
StatsTask = ENVITask('RasterStatistics')
StatsTask.INPUT_RASTER = Raster
StatsTask.Execute
minElevation = StatsTask.MIN
maxElevation = StatsTask.MAX
IndexTask = ENVITask('GenerateIndexArray')
IndexTask.MIN = minElevation
IndexTask.MAX = maxElevation
IndexTask.INCREMENT = 10
IndexTask.Execute
Task = ENVITask('GenerateContourLines')
Task.INPUT_RASTER = Raster
Task.LEVELS = IndexTask.OUTPUT_ARRAY
Task.OUTPUT_VECTOR_URI = e.GetTemporaryFilename('shp')
Task.Execute
DataColl = e.Data
DataColl.Add, Task.OUTPUT_VECTOR
View = e.GetView()
Layer = View.CreateLayer(Raster)
Layer2 = View.CreateLayer(Task.OUTPUT_VECTOR)
Version History
See Also
ENVITask, GenerateIndexArray Task, RasterStatistics Task