This function constructs an ENVIRaster from an input raster and a specified data range, where each pixel within the data range will not be masked.

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


; Start the application
e = ENVI()
; Open an input file
file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
  SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file)
; Set two different data ranges to mask
ranges = [[0, 350], [700, 10000]]
; Mask the input raster using the given data ranges
maskedRaster = ENVIDataValuesMaskRaster(raster, ranges)
; Display the new raster
view = e.GetView()
layer1 = view.CreateLayer(maskedRaster)

You can optionally save the masked raster to disk. However, be sure to set the DATA_IGNORE_VALUE keyword on the ENVIRaster::Export method as follows:

; Save the masked raster to a file
outFile = e.GetTemporaryFilename()
maskedRaster.Export, outFile, 'ENVI', DATA_IGNORE_VALUE=0

See Data Ignore Value for more information on choosing a suitable value.


Result = ENVIDataValuesMaskRaster(Input_Raster, Input_Ranges [, Keywords=value])

Return Value

The method returns an ENVIRaster, where the applied mask alters the pixel state of the raster. Use the PIXEL_STATE keyword of ENVIRaster::GetData or ENVIRasterIterator::GetData to determine which pixels to process. See Raster Pixel State for more details.



Specify an input ENVIRaster.


A (2,n) array of one or more data ranges where the first element of each range is the minimum data value to consider (inclusive) and the second element of each range is the maximum data value to consider (inclusive) for the pixels of the input raster.


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




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.

INVERSE (optional)

Set this keyword to invert the input mask. Pixels outside of the given data ranges will be masked in the output.


Specify a string that identifies the raster.

Version History

ENVI 5.3


ENVI 5.3.1

Documented the dehydrated form of this virtual raster

ENVI 5.4

Added Dehydrate and Hydrate Methods; added NAME keyword

API Version


See Also

ENVIRaster, ENVIMaskRaster, DataValuesMaskRaster Task, ENVIROIMaskRaster, ENVIVectorMaskRaster, CalculateCloudMaskUsingFmask Task, Masks