Customizing ENVI with IDL

Wednesday, March 20, 2013

Combining the large array of prepackaged analytical tools already available in ENVI with the programming power offered by IDL makes the ENVI+IDL platform and incredibly powerful platform for customized imagery analysis.


ENVI is a widely used and well respected Remote Sensing Data analysis application. Anyone working with imagery or raster data has probably encountered ENVI, even if just by name, at some point in their career. ENVI’s major strength lies in it’s robust analytical capabilities, giving it’s users fine grained control through each step of their analysis, as well as it’s ease of use and intuitive interface. ENVI has a wide array of tools for spatial and spectral analysis that are typically combined in an overall workflow that scientists, analysts, and production staff use to meet their needs in getting information from their imagery.

However, in the world of scientific analysis, off the shelf products like ENVI often don’t provide the necessary, specific functionality that a scientist needs to analyze the data they have. Many applications do 90% of the work a scientist needs, but fall just short of their overall application needs. To do their specific analyses, many scientists thusly have to create their own tools outside of the software applications they use. To achieve this end, the common approach is to pick a programming language that best suits the skills of the scientist and the needs of the analysis.

A variety of programming tools exist that all have benefits and drawbacks. Languages like C and Fortran can be very powerful and performant if written correctly, but require a certain level of expertise and a fair amount of code to do even simple tasks because they are low level languages. Other options like JavaScript or Perl are higher level scripting languages and thus far easier to use, but are much more restricted in their computing and optimization power and their overall functionality.

Intermediate options exist between these two, such as Java or IDL. These languages are interpreted and typically are far easier to learn and develop applications in because they don’t require tasks like memory management. IDL has even greater benefits because it also does not require typing or casting of variables which can significantly speed up the process of application development, particularly in the prototype or R&D phase, and it has a large library of routines in place for scientific data analysis and visualization.

Combining the large array of prepackaged analytical tools already available in ENVI with the programming power offered by IDL makes the ENVI+IDL platform and incredibly powerful platform for customized imagery analysis. ENVI can be extended or modified with IDL in several ways including access to an extensive analytical API, the ability to modify the user interface, access to the ENVI GUI elements, and the capability to use ENVI’s library in batch mode for production work or large, predefined processing tasks.

Overview of IDL

IDL (the Interactive Data Language) is a complete computing environment for the interactive analysis and visualization of data. IDL integrates a powerful, array-oriented language with numerous mathematical analysis and graphical display techniques. Programming in IDL is a time-saving alternative to programming in FORTRAN or C. Using IDL, tasks which require days or weeks of programming with traditional languages can be accomplished in hours. You can explore data interactively using IDL commands and then create complete applications by writing IDL programs.

Analysis advantages include:

  • Many numerical and statistical analysis routines—including Numerical Recipes routines—are provided for analysis and simulation of data. Compilation and execution of IDL commands provides instant feedback and hands-on interaction.
  • Operators and functions work on entire arrays (without using loops), simplifying interactive analysis and reducing programming time
  • IDL’s flexible input/output facilities allow you to read any type of custom data format.

Visualization advantages include:

  • Rapid 2D plotting, multi-dimensional plotting, volume visualization, image display, and animation allow immediate observation of your computation’s results.
  • Support for OpenGL-based hardware accelerated graphics

Application development advantages include:

  • IDL is a complete, structured language that can be used interactively and to create sophisticated functions, procedures, and applications.
  • IDL’s Intelligent Tools (iTools) can be customized with your own operations or data manipulations.
  • IDL widgets can be used to quickly create multi-platform graphical user interfaces to your IDL programs.
  • Existing FORTRAN and C routines can be dynamically-linked into IDL to add specialized functionality. Alternatively, C and FORTRAN programs can call IDL routines as a subroutine library or display engine.
  • IDL programs run across all supported platforms (UNIX, Macintosh and Microsoft Windows) with little or no modification. This application portability allows you to easily support a variety of computers.
Figure 1: A view of the IDL Workbench

Figure 1: A view of the IDL Workbench


Like IDL, ENVI has a library of built-in routines. In fact, there are over 200 documented routines in the ENVI library and it grows with each release. They encompass almost all of the functionality provided in the interactive ENVI program. Each library routine is written in the form of an IDL procedure or function, and is called as such. A complete index of these routines as well as a full reference page for each is located in the ENVI Online Help.

ENVI Library Routines

Library routines are IDL-based functions and procedures that you call from an IDL or ENVI command line (or incorporate into a user function or batch mode routine) that encompass nearly all of the functionality in ENVI. For example, the library routine MATH_DOIT lets you perform Band Math on a spatial dataset, just like you would by selecting Basic Tools – Band Math from the ENVI main menu bar. The ENVI library routines encompass programmatic access to a large collection of processing elements ranging from spectral analysis, region/area of interest processing, map projection utilities, object analysis, reporting, and visualization components. The ENVI Reference Guide contains a complete index and full reference page for each library routine.

Most of ENVI’s library routines require user interaction. When writing your own code to call ENVI library routines, you must explicitly handle all aspects of a library routine. As a result, most of the ENVI library routines require many more keywords than a typical IDL routine. Because so much information often must be passed into an ENVI library routine, they typically use keywords instead of positional parameters, to prevent you from having to pass information in a specific sequence.

Figure 2: Some Sample ENVI Library Code

Figure 2: Some Sample ENVI Library Code

To run a batch mode routine, start by creating a user function that contains the necessary ENVI program calls and appropriate parameters. Then run it using one of the following options:

  • From the ENVI menu system, which allows you to link a combination of processes and start them from a single menu option
  • From the IDL command line (assuming you have purchased ENVI + IDL), which allows you to perform common processing steps on various files outside of interactive ENVI. This capability can be useful in several cases: if you are primarily working in IDL but occasionally need to use ENVI routines; if you want to write user functions that combine your own IDL code with ENVI routines; or if you need to do a large amount of ENVI processing without any user interaction (for example, go home while the ENVI processing is performed overnight).

ENVI Interface Elements

ENVI Menu Files
The ENVI main menu bar (defined by and Display group menu bar (defined by are configurable items located in the menu subdirectory of the ENVI installation. These two ASCII files outline the placement of menu buttons, pull-down menus, and separators. They also define the procedure called when you select the menu item. You can reposition menu items or add new items, depending on your needs and preferences. ENVI does not distinguish between ENVI and user-event handlers, which ensures that user events are easily integrated. You can also use the ENVI_ DEFINE_MENU_BUTTON procedure to add menu items (buttons) to the ENVI menu system automatically through your own code.

Figure 3: The ENVI menu with buttons added<

Figure 3: The ENVI menu with buttons added


Using ENVI widgets to collect input in your user functions is much easier than adding widgets to an ordinary IDL program because there is no need to write your own event-handling procedures to manage the widget events; ENVI auto-manages the widget events for you. In addition, ENVI’s special compound widgets are included in the library of ENVI routines, making it easy to create user functions that have the same look-and-feel of ENVI. ENVI’s auto-managed widgets allow you to create user functions that fit seamlessly into ENVI.


When a widget interface for a user function is auto-managed by ENVI, the GUI is always modal. That is, the widget interface blocks the rest of ENVI from responding until you select the OK or Cancel button, either of which destroys the GUI (OK destroys and proceeds, and Cancel destroys and returns). In this mode, ENVI handles all of the widget events and conveniently returns the user input in a structure variable. Using ENVI to auto-manage the GUI in this fashion allows user functions to take a very simple form, where they can execute linearly from the beginning of the file to the end.


After writing a custom routine (user function, interactive user routine, or custom file reader), you should place the resulting .pro or .sav file in the save_add directory of your ENVI installation. This allows the routine to be automatically compiled or restored when ENVI is started. Use only lowercase names (including extensions) for files placed in the save_add directory. You can change the location of the save_add directory, as desired, in your ENVI preferences or configuration file.

As an alternative, you can compile .pro files within ENVI only if you have ENVI + IDL, by selecting File – Compile IDL Module from the ENVI main menu bar. This allows you to debug the routine during development. If you have standalone ENVI, you must use a compiled (.sav) file to add a user function to ENVI.

Custom File Input

You can write a custom file input routine to open and read your data format on-the-fly. When opening an unsupported file format automatically (without prompting for the file information), the input routine parses the file header and places the bands in the Available Bands List. Custom readers can access data stored in unsupported storage formats on-the-fly in ENVI, without converting to an ENVI format.


Exelis Visual Information Solutions recognizes the importance of giving users the power to customize and extend ENVI to meet their specific needs. Leveraging the power of IDL, along with access to the extensive analytic library of ENVI, allows users to create the functionality their application requires that can not be found in COTS products and to easily integrate this into the ENVI environment.

To learn more about ENVI features and functionality and more about customizing ENVI with IDL, visit or contact your ENVI sales representative.
Rate this article:
No rating

Number of views (14446)/Comments (0)

Please login or register to post comments.



Accuracy Assessment of Passive Point Clouds


Passive point clouds have become a pervasive data modality for remote sensing analyses. A passive point... more »

Geospatial Solutions in the Cloud


Geospatial analytics allow people to ask questions of data that exist within a spatial context. Usually... more »

Customizing ENVI with IDL


Combining the large array of prepackaged analytical tools already available in ENVI with the programming... more »

© 2017 Exelis Visual Information Solutions, Inc., a subsidiary of Harris Corporation