ENVILayerStackRaster

This function constructs a layer-stacked ENVIRaster from source rasters that have been regridded to a common spatial grid. The source rasters can be band groups within a metaspectral dataset (such as Landsat, ASTER, or Sentinel-2); or they can come from different raster files. The input rasters do not need to have the same number of columns and rows.

This is different than ENVIMetaspectralRaster, where the input rasters must have the same number of columns and rows and no reprojection or regridding will occur.

The result is a virtual raster, which has some additional considerations with regard to methods and properties. See Virtual Rasters for more information, including how they differ from ENVITasks.

The equivalent task is BuildLayerStack.

Example

This example creates a layer stack of Sentinel-2 Level-1C 10-meter, 20-meter, and 60-meter bands. It uses the spatial reference of the 10-meter raster to regrid the 20-meter and 60-meter bands to a common grid. Replace the filename in this script with your own filename. After the script runs, open the Data Manager to see all of the bands in the layer stack.

; Start the application

e = ENVI()

 

; Open a Sentinel-2 scene

file = 'S2A_OPER_MTD...xml' ; insert a real filename here

raster = e.OpenRaster(file)

 

; Get the 10-meter band group

bands10m = raster[0]

 

; Get the 20-meter band group

bands20m = raster[1]

 

; Get the 60-meter band group

bands60m = raster[2]

 

; Use the spatial reference of the 10-meter

; raster to create a common grid definition

; for the 20-meter and 60-meter rasters.

gridTask = ENVITask('BuildGridDefinitionFromRaster')

gridTask.INPUT_RASTER = bands10m

gridTask.Execute

 

; Create a layer stack

layerStack = ENVILayerStackRaster( $

  [bands10m, bands20m, bands60m], $

  GRID_DEFINITION=gridTask.OUTPUT_GRIDDEFINITION)

 

; Get the collection of data objects currently available in the Data Manager

DataColl = e.Data

 

; Add the output to the Data Manager

DataColl.Add, layerStack

 

; Display the result

view = e.GetView()

layer = view.CreateLayer(layerStack, /CIR)

view.Zoom, /FULL_EXTENT

Syntax

ENVIRaster = ENVILayerStackRaster(Input_Rasters [, Keywords=value])

Return Value

This routine returns a reference to an ENVIRaster.

Arguments

Input_Rasters

Specify an array of one or more ENVIRasters. In the case of Landsat or other metaspectral datasets, specify the correct array element corresponding to the band group you need. The sample code above shows this, using Sentinel-2 data as an example. See Working with Metaspectral Datasets for more information.

Arrange the rasters in the order you want them to appear in the layer stack.

Methods

This virtual raster inherits methods and properties from ENVIRaster; however the following methods will override the ENVIRaster methods:

Dehydrate

Hydrate

Keywords

GRID_DEFINITION (optional)

Specify an ENVIGridDefinition object that defines the pixel size, rows and columns, and coordinate system of the desired spatial reference. If this is not specified, then an ENVIGridDefinition will be constructed based on the first raster in the Input_Rasters array.

NAME

Specify a string that identifies the raster.

RESAMPLING (optional)

Specify the resampling method to use when creating the spatial grid:

ERROR (optional)

Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''). If an error occurs and the routine is a function, then the function result will be undefined.

When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.

See Manage Errors for more information on error handling in ENVI programming.

Version History

ENVI 5.3.2

Introduced

ENVI 5.4

Added Dehydrate and Hydrate methods; added NAME keyword

ENVI 5.5 Added RESAMPLING keyword

API Version

4.2

See Also

ENVIRaster, BuildLayerStack Task, ENVIMetaspectralRaster, BuildBandStack Task, ENVIGridDefinition, ENVISpatialGridRaster, ENVICoordSys