>  Docs Center  >  ENVI API  >  ENVITask::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.


This example shows a scenario where you may want to use the Hydrate method. The NUMBER_OF_CLASSES parameter in the ISODATA classification task accepts any number of classes; however, let's say that you want it to accept only 3, 5, 7, or 9 classes (with a default value of 5). You can modify the parameter to be a choice list instead. To do this requires accessing and editing the hash representation of the task.

; Start the application
; Get the task that will be modified
task = ENVITask('ClassificationAggregation')
; Retrieve the dehydrated hash
dehydratedForm = task.Dehydrate()
; Add a new CHOICE_LIST property value to the
; MINIMUM_SIZE parameter. This parameter is
; the second one in the list of parameters, so its 
; zero-based index is 1
dehydratedform['parameters', 1, 'choice_list'] = [3,5,7,9]
; Restore a new task from the updated hash
task2 = ENVITask.Hydrate(dehydratedForm)
; Verify that the modified parameter has the new
; property value
param = task2.Parameter('MINIMUM_SIZE')
Print, param, /IMPLIED_PRINT


NAME                      = 'MINIMUM_SIZE'
DISPLAY_NAME              = 'Minimum Size'
TYPE                      = 'UINT'
DESCRIPTION               = 'Specify the Aggregate Minimum Size in pixels. 
Regions with a size of this value or smaller are aggregated 
to an adjacent, larger region.'
DIRECTION                 = 'INPUT'
REQUIRED                  = false
DEFAULT                   = 9
VALUE                     = 9
CHOICE_LIST               = 3,5,7,9
INCLUSIVE_MAX             = true
INCLUSIVE_MIN             = true
MAX                       = !NULL
MIN                       = !NULL
TEST_EXACT                = false
TEST_OVERFLOW             = true


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

Return Value

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



See Sample Task Template.



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


API Version


See Also


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