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


  >  Docs Center  >  ENVI API  >  Data Control  >  ENVILayerStackRaster

ENVILayerStackRaster

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 ENVIBuildLayerStackTask.

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

See More Examples.

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:

  • Nearest Neighbor (default): Uses the nearest pixel without any interpolation.
  • Bilinear: Performs a linear interpolation using four pixels to resample.
  • Cubic Convolution: Uses 16 pixels to approximate the sinc function using cubic polynomials to resample the image.

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.

More Examples


This example creates one raster that consists of a red band (Band 4) from a Landsat-1 MSS image and a red band (Band 2) from a Landsat TM image. The images have a different number of rows and columns. The pixel size is 60 meters for MSS and 30 meters for TM. They are both in the same coordinate system. Because their dimensions are different, you must use ENVILayerStackRaster to create a georeferenced layer stack.

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. Copy the images to your local drive, and update the file location with your own directory.

; Start the application
e = ENVI()
 
; Select a Landsat MSS scene from 1975
File1 = 'LasVegasMay1975.dat'
Raster1 = e.OpenRaster(File1)
 
; Select a Landsat TM scene from 2005
File2 = 'LasVegasMay2005.dat'
Raster2 = e.OpenRaster(File2)
 
; Get the red band (4) from the 1975 scene.
; Bands are zero-based.
; For Landsat-1 MSS through Landsat-3 MSS:
;   0 = Band 4
;   1 = Band 5
;   2 = Band 6
;   3 = Band 7
RedMSSRaster = ENVISubsetRaster(Raster1, BANDS=0)
 
; Get the red band (2) from the 2005 scene.
RedTMRaster = ENVISubsetRaster(Raster2, BANDS=1)
 
; Use the spatial reference of the TM scene to
; create a common grid definition for the MSS scene
gridTask = ENVITask('BuildGridDefinitionFromRaster')
gridTask.INPUT_RASTER = RedTMRaster
gridTask.Execute
 
; Create a layer stack of the two scenes
layerStack = ENVILayerStackRaster( $
  [RedMSSRaster, RedTMRaster], $
  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, BANDS=0)
layer = view.CreateLayer(layerStack, BANDS=1)
view.Zoom, /FULL_EXTENT
view.Animate, /FLICKER

Version History


ENVI 5.3, Service Pack 2

Introduced

ENVI 5.4

Added Dehydrate and Hydrate methods; added NAME keyword

ENVI 5.5 Added RESAMPLING keyword

API Version


3.3

See Also


ENVIRaster, ENVIBuildLayerStackTask, ENVIMetaspectralRaster, ENVIBuildBandStackTask, ENVIGridDefinition, ENVISpatialGridRaster, ENVICoordSys



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