This task subsets a raster spatially (by geographic location) and/or spectrally.

Example


; Start the application
e = ENVI()
 
; Open an input file
File = Filepath('qb_boulder_msi', Subdir=['data'], $
  Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
 
; Define the spatial range of the subRect
subRect = [Raster.nSamples/4, Raster.nLines/4, $
  Raster.nSamples*3/4, Raster.nLines*3/4]
 
; Get the spatial reference of the raster
SpatialRef = Raster.SPATIALREF
 
; Convert file coordinates to map coordinates
SpatialRef.ConvertFileToMap, subRect[0], subRect[1], ULx, ULy
SpatialRef.ConvertFileToMap, subRect[0], subRect[3], LLx, LLy
SpatialRef.ConvertFileToMap, subRect[2], subRect[1], URx, URy
SpatialRef.ConvertFileToMap, subRect[2], subRect[3], LRx, LRy
geoRect = [ LLx, LLy, URx, URy ]
 
; Get the task from the catalog of ENVITasks
Task = ENVITask('GeographicSubsetRaster')
 
; Define inputs
Task.INPUT_RASTER = Raster
Task.SUB_RECT = geoRect
 
; 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_RASTER
 
; Display the result
View = e.GetView()
Layer1 = View.CreateLayer(Task.OUTPUT_RASTER)

Syntax


Result = ENVITask('GeographicSubsetRaster')

Input parameters (Set, Get): BANDS, INPUT_RASTER, OUTPUT_RASTER_URI, SPATIAL_REFERENCE, SUB_RECT

Output parameters (Get only): OUTPUT_RASTER

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


BANDS (optional)

Specify an array of band indices to include in the OUTPUT_RASTER. The indices are zero-based, and a scalar is allowed for single-band output.

INPUT_RASTER (required)

Specify the input ENVIRaster to subset.

OUTPUT_RASTER_URI (optional)

Specify a string with the fully qualified filename and path to export the associated OUTPUT_RASTER.

  • If you set this parameter to an asterisk symbol (*), the output raster will be virtual and not written to disk.
  • If you do not specify this parameter, or set it to an exclamation symbol (!), a temporary file will be created.
  • If you set it to the hash symbol (#), ENVI creates a file in the temporary directory, but this file will not be deleted when ENVI closes.

SPATIAL_REFERENCE (optional)

Specify an ENVIPseudoRasterSpatialRef, ENVIRPCRasterSpatialRef, or ENVIStandardRasterSpatialRef object that indicates the spatial reference of the spatial subset. If you do not specify this parameter, ENVI will use the spatial reference of the input raster by default.

SUB_RECT (required)

Set this parameter to a four-element array expressing the spatial range of the raster data. The array is of the form [minX, minY, maxX, maxY]

Values can be map coordinates (x=eastings, y=northings) or geographic coordinates (x=longitude, y=latitude), depending on the spatial reference object used.

Output Parameters


OUTPUT_RASTER

This is a reference to the output raster of filetype ENVI.

Methods


Execute

Parameter

ParameterNames

Properties


DESCRIPTION

DISPLAY_NAME

NAME

REVISION

TAGS

Version History


ENVI 5.2.1

Introduced

ENVI 5.5

OUTPUT_RASTER_URI now supports '*', which allows OUTPUT_RASTER to be virtual output.

See Also


ENVITask, SubsetRaster Task, ENVISubsetRaster, Masking Support in ENVITasks