This method has been deprecated. Use ENVIRaster::Export instead.

The ExportRaster method allows the user the save a raster to a specific format. This method creates a new file, but does not change the existing raster.


; Launch the application
e = ENVI()
; Create an ENVIRaster
file = FILEPATH('qb_boulder_pan', ROOT_DIR=e.ROOT_DIR, $
  SUBDIRECTORY = ['data'])
raster1 = e.OpenRaster(file)
; Create a scratch output file
newFile = e.GetTemporaryFilename()
; Export a subset of the raster as a TIFF file
e.ExportRaster, raster1, newFile, 'TIFF', SUB_RECT=[500,2500,1699,3999]
; Open the TIFF file
raster2 = e.OpenRaster(newFile)
view = e.GetView()
layer = view.CreateLayer(raster2)


ENVI.ExportRaster, Raster, URI, Format [, BANDS = array] [, DTED_LEVEL={0|1|2}] [, ERROR=variable] [, NITF_COMPRESSION=string] [, SUB_RECT=array]



A reference to an existing ENVIRaster object to export.

If exporting as a NITF file, Raster can be an array of raster segments from a multi-segment NITF file.


A scalar string denoting the fully-qualified filepath in which the raster will be saved.


A scalar string denoting the format in which the raster(s) will be saved. An error will be thrown if the format is unrecognized or unsupported by the raster. The valid string values are:

Format Strings Notes

The Digital Terrain Elevation Data (DTED) format is supported if the raster has only one band.

Set the level using the DTED_LEVEL keyword.

'nitf' Set the National Imagery Transmission Format (NITF) compression type with the NITF_COMPRESSION keyword.


Keywords are applied only during the initial creation of the object.

Note: Keywords not associated with the given format are quietly ignored.


Set this keyword to an n-element array expressing the integer indices (0-based) of the bands to be included in the data that will be exported. By default, all bands will be included.


If you used 'dted' as the Format value, set this keyword to an integer denoting the DTED level (0, 1, or 2).

If exporting as a DTED file and DTED_LEVEL is not set, the default value is 1.


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.


If you used 'nitf' as the Format value, set this keyword to a string denoting the NITF compression type. (These strings also appear in the ENVI File > Save As... menu dialog).

The valid string values are:

'epje num lossless' 
'epje vis lossless'
'jpeg dct (high)'
'jpeg dct (low)'
'jpeg dct (medium)'
'no compression'
'npje num lossless'
'npje vis lossless' 
'transcode epje to npje'
'transcode npje to epje'

The default is 'no compression'.


Set this keyword to a four-element array expressing the spatial range (in pixels) of the data. The array is of the form [x1, y1, x2, y2], where:

x1 = First pixel of the columns dimension

y1 = First pixel of the rows dimension

x2 = Last pixel of the columns dimension

y2 = Last pixel of the rows dimension

Pixel coordinates are zero-based.

Version History



ENVI 5.1

Deprecated. Use ENVIRaster::Export instead.

See Also

ENVIRaster, ENVIRaster::Save