Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.

  >  Docs Center  >  Using ENVI  >  Generate and Run Code From Models


Generate and Run Code From Models

Generate and Run Code From Models

This topic describes options for generating and running code from models. See the following sections:

IDL Programs and ENVI Toolbox Extensions

To generate IDL code for a model, select Code > Generate IDL Program from the ENVI Modeler menu bar. You must have an ENVI+IDL license to use this feature. The IDL code is displayed in a new Program window; for example:

From here, you can do the following:

  • To save the program to an IDL program file (.pro), click the Save button .
  • To run the program, click the Run button.
  • To create a tool from the model that you can add to the ENVI Toolbox, click the Create Extension button. In the Create ENVI Extension dialog, provide a name for the tool in the Extension Name field. The default location for saving the extension is shown. If you want to change this, select another option from the drop-down list. Click OK. The tool will be listed under the Extensions folder in the ENVI Toolbox.

Python Programs

You can generate Python code for a model if you want to use Python to call the ENVI Task Engine. To run the Python code that is generated, you must have the following installed:

Select Code > Generate Python Program from the ENVI Modeler menu bar. The Python code is displayed in a new Program window; for example:

From here, you can do the following:

  • To save the program to a Python program file (.py), click the Save button .
  • To run the program, click the Run button.
  • To configure the output directory of the Python program, click the Configure Task Engine button . Enter an Output Directory and click OK. All of the files generated by the model will be written to that directory.

When running a Python program, the results will not be displayed or added to the Data Manager in ENVI. All of the output rasters or vectors that are connected to an Output Parameters node will be preserved in the output folder. Other intermediate files that are created will be immediately deleted upon running the program.


You can save a model to a task file (.task) on disk so that you can share the task with others or use it in the ENVI API, similar to a custom task.

Follow these steps to save a model as a task file:

  1. Decide what inputs and outputs your metatask needs to expose. See Define Metatask Inputs and Outputs in the Create Models topic for details.
  2. Select Code > Generate Metatask from the ENVI Modeler menu bar. The task code is displayed in a new Metatasks dialog.
  3. Choose a save option using the Save button or Publish Task option:

Save Button

Click the Save button in the Metatask dialog. Select an output filename and directory for the .task file. See Deploy Custom Task Files in the ENVI API Programming Guide for recommendations on where to save .task files on your system.

Publish Task

The Publish Task option is similar to the Save option, except that it makes the task known to the current ENVI session and adds it to the Task list in the ENVI Modeler. It automatically saves the .task file to the preferred location on your system. This is the custom_codex_x folder under your default IDL preferences directory, where x_x is the ENVI software version. For example:

  • Windows: C:\Users\<username>\.idl\custom_codex_x
  • Linux: /users/<username>/.idl/custom_codex_x
  • Macintosh: /Users/<username>.idl/custom_codex_x

Follow these steps:

  1. Click Publish Task in the Metatask dialog. In the Publish Metatask dialog, enter a Name, Display Name, and optional Description for the task. The Display Name is the name of the task as it appears to the end user.
  2. Enter a Revision number for the task. This is a string with the semantic revision number of the task. Semantic versioning provides a quick way to extract information about a new task. The default value is 1.0.0.
  3. Optionally enter a comma-separated list of Tags to categorize the task by function. See the Search Tags section of the Create Models topic for more information about tags.
  4. The default location for saving the task is shown. To change this, select another option from the drop-down list.
  5. If you want to publish the task to ArcMap or ArcGIS Pro check the appropriate box; this will make the task available to use directly from the ArcMap and/or ArcGIS Pro system toolbox the next time the product is started. Click OK. To publish to ArcMap, both ArcMap and ENVI Py for ArcMap must also be installed. To publish to ArcGIS Pro, both ArcGIS Pro and ENVI Py for ArcGIS Pro must also be installed.

Geospatial Services Framework

If you have Geospatial Services Framework (GSF) installed, you can run a model on a GSF server. Select Server > Add GSF Server from the ENVI Modeler menu bar. Enter the GSF endpoint URI in the Connection field and click OK. A typical endpoint is http://server:port/ese/services/ENVI, where server and port are the GSF server and port number. From then on, you can run models on that server by selecting Server > Run on endpoint. For more information about GSF, see the GSF documentation on the Harris Geospatial Systems documentation center.

The Modeler will generate a metatask from your model to run as a single GSF job. The GSF job output will only include parameters from the Output Parameters nodes in your model.

Note: Input and output data must reference the same shared network resource. For example, if your input dataset is on a local drive, the GSF server will not be able to access it. Make sure that input files are in a shared network resource, and set the output files to a network location that you can access.

See Also

ENVI Modeler Examples, Getting Started with the ENVI Modeler, Create Models, Toolbox Extensions, Metatasks, Custom Tasks, Deploy Custom Task Files, Run ENVI Analytics at the Command Line

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