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

  >  Docs Center  >  ENVI API  >  Processing  >  ENVIBuildBandStackTask



This task builds a band-stacked raster (also called a metaspectral raster), which is a stack of ENVIRasters with the same dimensions. A common use is to include bands from different rasters.

  • The input rasters must have the same number of rows and columns.
  • The input rasters can have different pixel sizes.
  • The input rasters do not need to be georeferenced, but you can georeference the resulting metaspectral raster using the SPATIALREF keyword.
  • The input rasters can be of different interleave types, but the resulting metaspectral raster will be BSQ.
  • The input rasters can be of different data types, but the resulting metaspectral raster will be cast to the highest data type out of all the rasters.
  • See Working with Metaspectral Datasets in the ENVI API for guidelines on using Landsat and ASTER imagery.


This example creates one raster that consists of Band 2 from a 1984 Landsat TM image and Band 2 from a 2005 TM image. Both images have the same number of rows and columns; they are also in the same coordinate system and have the same pixel size (30 m).

The example uses sample images from the ENVI Resource DVD (in the LandsatCaseStudies\TimeSeries folder). The images are also available from the ENVI Tutorials web page. Click the "ENVI Tutorial Data" hyperlink. Copy the images to your local drive, and update the file location with your own directory.

; Start the application
e = ENVI()
; Select a Landsat TM scene from 1985
File1 = 'LasVegasTM5May1985.dat'
Raster1 = e.OpenRaster(File1)
; Select a Landsat TM scene from 2005
File2 = 'LasVegasTM5May2005.dat'
Raster2 = e.OpenRaster(File2)
; Get the red band (2) from the 1985 scene.
; Bands are zero-based.
RedRaster1 = ENVISubsetRaster(Raster1, BANDS=1)
; Get the red band (2) from the 2005 scene.
RedRaster2 = ENVISubsetRaster(Raster2, BANDS=1)
; Get the task from the catalog of ENVITasks
Task = ENVITask('BuildBandStack')
; Define inputs
Task.INPUT_RASTERS = [RedRaster1, RedRaster2]
; Define outputs
Task.OUTPUT_RASTER_URI = e.GetTemporaryFilename()
; Run the task
; 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
View1 = e.GetView()
Layer1 = View1.CreateLayer(Task.OUTPUT_RASTER)
Layer2 = View1.CreateLayer(Task.OUTPUT_RASTER, BANDS=[1])
View1.Zoom, /FULL_EXTENT
View1.Animate, 2.0, /FLICKER


Result = ENVITask('BuildBandStack')


Output properties (Get only): OUTPUT_RASTER

Properties marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Properties marked as "Get" are those whose values you can retrieve but not set.


This task inherits the following methods from ENVITask:







This task inherits the following properties from ENVITask:







This task also contains the following properties:

INPUT_RASTERS (required)

Specify an array of ENVIRasters from which to build a band-stacked raster.


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


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

  • If you set this property to an asterisk symbol (*), the output raster will be virtual and not written to disk.
  • If you do not specify this property, or set it to an exclamation symbol (!), a temporary file will be created.


Set this keyword to an ENVIStandardRasterSpatialRef, ENVIPseudoRasterSpatialRef, or ENVIRPCRasterSpatialRef object to be used by OUTPUT_RASTER. If this keyword is not specified, then the first valid SPATIALREF property found in the INPUT_RASTERS array will be used.

Version History

ENVI 5.2


ENVI 5.5

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

API Version


See Also

ENVITask, ENVITask::Parameter, ENVIMetaspectralRaster, ENVIRegridRasterTask, ENVISubsetRaster

© 2018 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us