ENVICastRaster
This function creates an ENVIRaster from a source raster where pixel values have been cast to a specified data type; for example, unsigned integer or double-precision floating point.
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 CastRaster.
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)
; Cast the raster to floating point values
castRaster = ENVICastRaster(raster, 'float')
; Display the result
View = e.GetView()
Layer = View.CreateLayer(castRaster)
Syntax
Result = ENVICastRaster(Input_Raster, Data_Type [, Keywords=value])
Return Value
This function returns a reference to an ENVIRaster.
Arguments
Input_Raster
Specify an input ENVIRaster.
Data_Type
Specify a string indicating the data type to cast the pixel values to. Choose one of the following values, which are supported by any ENVIRaster:
byte
: An 8-bit unsigned integer ranging in value from 0 to 255.int
: A 16-bit signed integer ranging from -32,768 to +32,767.long
: A 32-bit signed integer ranging in value from -2,147,483,648 to +2,147,483,647.float
: A 32-bit, single-precision, floating-point number in the range of ±1038, with approximately six or seven significant digits.double
: A 64-bit, double-precision, floating-point number in the range of ±10308 with approximately 15 or 16 significant digits.uint
: A 16-bit unsigned integer ranging from 0 to 65,535.ulong
: A 32-bit unsigned integer ranging in value from 0 to 4,294,967,295.
Note: Casting a floating-point raster to integer will truncate the data values. Overflow will occur when the original value is greater than the maximum value for the output data type.
Methods
Keywords
DATA_IGNORE_VALUE (optional)
Set this keyword to a numeric pixel value that will be ignored upon export. The pixel state of the output raster will be the same as that of the input raster, regardless of whether or not it was set. The data ignore value should be different from any other pixel value in the input raster, in order to avoid masking out good pixels during export.
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.
NAME
Specify a string that identifies the raster.
Version History
ENVI 5.4.1 |
Introduced |
API Version
4.2
See Also