ENVIVectorMaskRaster
This function constructs an ENVIRaster from an input raster and an ENVIVector that defines the area not to mask. Each pixel inside the polygon, along the polyline, or under the point 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 VectorMaskRaster.
Example
; 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)
; Select input vector data
vectorFile = Filepath('qb_boulder_msi_vectors.shp', SUBDIR=['data'], $
ROOT_DIR=e.Root_Dir)
vector = e.OpenVector(vectorFile)
; Mask the input raster using all the records from the vector data
maskedRaster = ENVIVectorMaskRaster(raster, vector)
; Display the new raster. The masked areas are transparent.
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.
Syntax
Result = ENVIVectorMaskRaster(Input_Raster, Input_Vector [, 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.
Arguments
Input_Raster
Specify an input ENVIRaster.
Input_Vector
Specify an input ENVIVector.
Methods
This virtual raster inherits methods and properties from ENVIRaster; however the following methods will override the ENVIRaster methods:
Keywords
ERROR
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
Set this keyword to invert the input vector. Each pixel inside the polygon, along the polyline, or under the point will be masked.
NAME
Specify a string that identifies the raster.
Version History
ENVI 5.2. 1 |
Introduced |
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
4.2
See Also
ENVIRaster, ENVIVector, Masks, GenerateMaskFromVector Task, ENVIDataValuesMaskRaster, ENVIMaskRaster, ENVIROIMaskRaster, VectorMaskRaster Task