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.
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.
e = ENVI()
file = 'S2A_OPER_MTD...xml'
raster = e.OpenRaster(file)
bands10m = raster
bands20m = raster
bands60m = raster
gridTask = ENVITask('BuildGridDefinitionFromRaster')
gridTask.INPUT_RASTER = bands10m
layerStack = ENVILayerStackRaster( $
[bands10m, bands20m, bands60m], $
DataColl = e.Data
view = e.GetView()
layer = view.CreateLayer(layerStack, /CIR)
ENVIRaster = ENVILayerStackRaster(Input_Rasters [, Keywords=value])
This routine returns a reference to an ENVIRaster.
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.
This virtual raster inherits methods and properties from ENVIRaster; however the following methods will override the ENVIRaster methods:
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.
Specify a string that identifies the raster.
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.
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.
Added Dehydrate and Hydrate methods; added NAME keyword
||Added RESAMPLING keyword
ENVIRaster, BuildLayerStack Task, ENVIMetaspectralRaster, BuildBandStack Task, ENVIGridDefinition, ENVISpatialGridRaster, ENVICoordSys