>  Docs Center  >  ENVI API  >  Data Control  >  ENVIMetaspectralRaster::Hydrate



Use the Hydrate static function method to create the object from its dehydrated form. The dehydrated form consists of a hash containing the object’s properties and values. The Hydrate and Dehydrate methods let you store the object state in memory and restore it later.

Representing an object as a hash is necessary for running ENVI analytics with the ENVI Task Engine and the ENVI Services Engine.

See the ENVIHydrate function if you are creating a general IDL routine that will restore multiple object types.


; Start the application
; Select a Landsat-8 metadata file
File = 'LC80410302013229LGN00_MTL.txt'
Raster = e.OpenRaster(File)
; Landsat-8 data are stored in a 5-element
; array. Multispectral bands are stored in the
; first array element. Thermal bands are stored
; in the fourth array element.
OLIBands = Raster[0]
TIRBands = Raster[3]
; Create a metaspectral raster
MSRaster = ENVIMetaspectralRaster([OLIBands,TIRBands])
; Retrieve the dehydrated hash
dehydratedForm = MSRaster.Dehydrate()
; Restore the object
newImage = ENVIMetaspectralRaster.Hydrate(dehydratedForm)
Print, newImage, /IMPLIED_PRINT


Result = ENVIMetaspectralRaster.Hydrate(DehydratedForm, ERROR=value)

Return Value

The result is a reference to a new object instance of this virtual raster class.






Required. A string value of MetaspectralRaster indicating what object type the hash represents.


Required. A list of input ENVIRasters for use in ENVI processing. The following example uses a fictitious filename for illustration:

"input_rasters": [
  "factory" : "URLRaster",
  "dataset_name" : "multispectral",
  "dataset_index" : 0,
  "url" : "/usr/local/data/landsat8_MTL.txt"
  "factory" : "URLRaster",
  "dataset_name" : "cirrus",
  "dataset_index" : 2,
  "url" : "/usr/local/data/landsat8_MTL.txt"
  "factory" : "URLRaster",
  "dataset_name" : "thermal",
  "dataset_index" : 3,
  "url" : "/usr/local/data/landsat8_MTL.txt"


A string that identifies the raster.


The hash representation of a spatial reference of type ENVIStandardRasterSpatialRef, ENVIPseudoRasterSpatialRef or ENVIRPCRasterSpatialRef. Example:

spatialRef: {      
  "factory": "StandardRasterSpatialRef",
  "rotation": 0.00000000,
  "tie_point_pixel": [0.00000000, 0.00000000],      
  "coord_sys_code": 32611,      
  "pixel_size": [30.000000, 30.000000],
  "tie_point_map": [493785.00, 4899315.0]


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.

Version History

ENVI 5.4


API Version


See Also

ENVIMetaspectralRaster, ENVIMetaspectralRaster::Dehydrate, ENVIHydratable, ENVIHydrate

© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us