This function constructs an ENVIRaster from a source raster that has gains and offsets applied. The output raster can be used for a custom calibration routine.

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


; Start the application
e = ENVI()
; Open an input file
File = Filepath('bhtmref.img', Subdir=['classic', 'data'], $
Raster = e.OpenRaster(File)
; Specify the gains and offsets
Gains = [2.00, 1.33, 1.20, 1.11, 2.60, 3.12]
Offsets = [12.33, 1.10, 6.00, 1.55, 5.32, 4.05]
GainOffsetImage = ENVIGainOffsetRaster(Raster, Gains, Offsets)
; save it in ENVI raster format
newFile = e.GetTemporaryFilename()
GainOffsetImage.Export, newFile, 'ENVI'
; Open the image
GainOffsetImage = e.OpenRaster(newFile)
; Display the result
View = e.GetView()
Layer = View.CreateLayer(GainOffsetImage)


Result = ENVIGainOffsetRaster(Input_Raster, Gain, Offset, ERROR=variable)

Return Value

This routine returns a reference to an ENVIRaster.



Specify the input ENVIRaster.


Specify a double-precision array of data gain values, one per band, to apply to the input raster.


Specify a double-precision array of data offset values, one per band, to apply to 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.


Specify a string that identifies the raster.

Version History

ENVI 5.2.1


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, ApplyGainOffset Task