IDL ENVI Reference Guide PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 774

ENVI Reference

Guide

ENVI Version 4.2


August, 2005 Edition
Copyright Research Systems, Inc.
All Rights Reserved

20REF42DOC

Restricted Rights Notice


The ENVI, IDL, ION Script, and ION Java software programs and the accompanying procedures, functions, and documentation described herein are sold under license agreement. Their
use, duplication, and disclosure are subject to the restrictions stated in the license agreement.
Research System, Inc., reserves the right to make changes to this document at any time and without
notice.

Limitation of Warranty
Research Systems, Inc. makes no warranties, either express or implied, as to any matter not
expressly set forth in the license agreement, including without limitation the condition of the software, merchantability, or fitness for any particular purpose.
Research Systems, Inc. shall not be liable for any direct, consequential, or other damages suffered
by the Licensee or any others resulting from use of the ENVI, IDL, and ION software packages or
their documentation.

Permission to Reproduce this Manual


If you are a licensed user of these products, Research Systems, Inc. grants you a limited, nontransferable license to reproduce this particular document provided such copies are for your use only
and are not sold or distributed to third parties. All such copies must contain the title page and this
notice page in their entirety.

Acknowledgments
ENVI and IDL are registered trademarks of Research Systems Inc., registered in the United States Patent and Trademark Office,
for the computer program described herein. ION, ION Script, ION Java, Dancing Pixels, Pixel Purity Index, PPI, n-Dimensional Visualizer, Spectral Analyst, Spectral Feature Fitting, SFF, Mixture-Tuned Matched Filtering, MTMF, 3D SurfaceView, Band
Math, Spectral Math, ENVI Extension, Empirical Flat Field Optimal Reflectance Transformation (EFFORT), Virtual Mosaic, ENVI
DEM Extraction Module, and ENVI NITF Module are trademarks of Research Systems, Inc.
Numerical Recipes is a trademark of Numerical Recipes Software. Numerical Recipes routines are used by permission.
GRG2 is a trademark of Windward Technologies, Inc. The GRG2 software for nonlinear optimization is used by permission.
NCSA Hierarchical Data Format (HDF) Software Library and Utilities. Copyright 1988-1998 The Board of Trustees of the University of Illinois. All rights reserved.
NCSA HDF5 (Hierarchical Data Format 5) Software Library and Utilities. Copyright 1998, 1999, 2000, 2001, 2002 by the Board of
Trustees of the University of Illinois. All rights reserved.
CDF Library. Copyright 1999 National Space Science Data Center, NASA/Goddard Space Flight Center.
NetCDF Library. Copyright 1993-1996 University Corporation for Atmospheric Research/Unidata.
HDF EOS Library. Copyright 1996 Hughes and Applied Research Corporation.
SMACC. Copyright 2000-2004 Spectral Sciences, Inc. and Research Systems, Inc. All rights reserved.
This software is based in part on the work of the Independent JPEG Group.
Portions of this software are copyrighted by INTERSOLV, Inc., 1991-1998.
BandMax Copyright 2003 The Galileo Group Inc.
Portions of this computer program are copyright 1995-1999 LizardTech, Inc. All rights reserved. MrSID is protected by U.S. Patent
No. 5,710,835. Foreign Patents Pending.
This product includes software developed by the Apache Software Foundation (http://www.apache.org/).
Portions of ENVI were developed using Unisearchs Kakadu software, for which RSI has a commercial license. Kakadu Software.
Copyright 2001. The University of New South Wales, UNSW, Sydney NSW 2052, Australia, and Unisearch Ltd, Australia.
MODTRAN is licensed from the United States of America under U.S. Patent No. 5,315,513 and U.S. Patent No. 5,884,226.
FLAASH is licensed from Spectral Sciences, Inc. under a U.S. Patent Pending.
Other trademarks and registered trademarks are the property of the respective trademark holders.

Contents
Chapter 1
Overview ................................................................................................ 11
How to Use this Reference Section .................................................................................
Alphabetic List of ENVI Routines ..................................................................................
Functional List of Basic ENVI Routines .........................................................................
Quick Reference of ENVI Library Function Variable Codes .........................................

12
18
33
41

Chapter 2
ENVI Routines ....................................................................................... 46
ADAPT_FILT_DOIT ......................................................................................................
AIRSAR_HEADER_DOIT .............................................................................................
AIRSAR_PED_HEIGHT_DOIT ....................................................................................
AIRSAR_PHASE_IMAGE_DOIT .................................................................................
AIRSAR_POLSIG_DOIT ...............................................................................................
AIRSAR_SCATTER_DOIT ...........................................................................................
AIRSAR_SYNTH_DOIT ...............................................................................................
ENVI Reference Guide

47
52
54
57
60
63
67
3

ASPECT_DOIT ............................................................................................................... 71
AUTO_WID_MNG ......................................................................................................... 74
BAD_DATA_DOIT ........................................................................................................ 75
CATCH ............................................................................................................................ 78
CF_DOIT ......................................................................................................................... 79
CLASS_CONFUSION_DOIT ......................................................................................... 82
CLASS_CS_DOIT ........................................................................................................... 87
CLASS_DOIT .................................................................................................................. 91
CLASS_MAJORITY_DOIT ......................................................................................... 102
CLASS_RULE_DOIT ................................................................................................... 105
CLASS_STATS_DOIT ................................................................................................. 108
COM_CLASS_DOIT .................................................................................................... 112
CONTINUUM_REMOVE_DOIT ................................................................................. 115
CONV_DOIT ................................................................................................................. 118
CONVERT_DOIT ......................................................................................................... 122
CONVERT_INPLACE_DOIT ...................................................................................... 125
CROSS_TRACK_CORRECTION_DOIT .................................................................... 128
DARK_SUB_DOIT ....................................................................................................... 133
DECOR_DOIT .............................................................................................................. 136
DEM_BAD_DATA_DOIT ............................................................................................ 139
DESKEW_DOIT ........................................................................................................... 142
DESTRIPE_DOIT ......................................................................................................... 145
DISP_GET_LOCATION ............................................................................................... 148
DISP_GOTO .................................................................................................................. 150
DISP_OUT_IMG ........................................................................................................... 152
ELINE_CAL_DOIT ...................................................................................................... 155
EMITTANCE_CALC_DOIT ........................................................................................ 158
ENVI .............................................................................................................................. 161
ENVI_ADD_PROJECTION ......................................................................................... 162
ENVI_ASSIGN_HEADER_VALUE ............................................................................ 163
ENVI_AUTO_TIE_POINTS_DOIT ............................................................................. 166
ENVI_AVHRR_CALIBRATE_DOIT .......................................................................... 176
ENVI_AVHRR_GEOMETRY_DOIT .......................................................................... 179
ENVI_AVHRR_WARP_DOIT ..................................................................................... 182
ENVI_BANDMAX_SELECT_BANDS ....................................................................... 186
ENVI_BATCH_EXIT ................................................................................................... 190
Contents

ENVI Reference Guide

ENVI_BATCH_INIT ....................................................................................................
ENVI_BATCH_STATUS_WINDOW .........................................................................
ENVI_BUFFER_ZONE_DOIT ....................................................................................
ENVI_CAL_DOIT ........................................................................................................
ENVI_CENTER ............................................................................................................
ENVI_CLOSE_DISPLAY ............................................................................................
ENVI_CLOVER_DOIT ................................................................................................
ENVI_COLLECT_SPECTRA ......................................................................................
ENVI_COMPUTE_SUN_ANGLES .............................................................................
ENVI_CONVERT_FILE_COORDINATES ................................................................
ENVI_CONVERT_FILE_MAP_PROJECTION .........................................................
ENVI_CONVERT_LIDAR_DATA_DOIT ..................................................................
ENVI_CONVERT_PROJECTION_COORDINATES ................................................
ENVI_CREATE_ROI ...................................................................................................
ENVI_CUBE_3D_DOIT ..............................................................................................
ENVI_DEFAULT_STRETCH_CREATE ....................................................................
ENVI_DEFINE_MENU_BUTTON .............................................................................
ENVI_DEFINE_ROI ....................................................................................................
ENVI_DELETE_ROIS .................................................................................................
ENVI_DISP_QUERY ...................................................................................................
ENVI_DISPLAY_BANDS ...........................................................................................
ENVI_DOIT ..................................................................................................................
ENVI_ENTER_DATA .................................................................................................
ENVI_ENVISAT_GEOREF_DOIT .............................................................................
ENVI_EVF_CLOSE .....................................................................................................
ENVI_EVF_DEFINE_ADD_RECORD .......................................................................
ENVI_EVF_DEFINE_CLOSE .....................................................................................
ENVI_EVF_DEFINE_INIT ..........................................................................................
ENVI_EVF_INFO .........................................................................................................
ENVI_EVF_OPEN .......................................................................................................
ENVI_EVF_READ_RECORD .....................................................................................
ENVI_EVF_TO_SHAPEFILE .....................................................................................
ENVI_FILE_MNG ........................................................................................................
ENVI_FILE_QUERY ...................................................................................................
ENVI_FILE_TYPE .......................................................................................................
ENVI_FILTER_DOIT ..................................................................................................
ENVI Reference Guide

192
194
197
200
203
204
205
208
211
213
215
220
225
228
230
233
236
244
247
248
251
254
257
265
269
271
275
279
283
286
288
290
292
293
301
304

Contents

ENVI_GEOREF_FROM_GLT_DOIT .......................................................................... 307


ENVI_GET_CONFIGURATION_VALUES ................................................................ 311
ENVI_GET_DATA ....................................................................................................... 312
ENVI_GET_DISPLAY_NUMBERS ............................................................................ 315
ENVI_GET_FILE_IDS ................................................................................................. 316
ENVI_GET_HEADER_VALUE .................................................................................. 317
ENVI_GET_IMAGE ..................................................................................................... 321
ENVI_GET_MAP_INFO .............................................................................................. 323
ENVI_GET_PATH ........................................................................................................ 325
ENVI_GET_PROJECTION .......................................................................................... 326
ENVI_GET_RGB_TRIPLETS ...................................................................................... 328
ENVI_GET_ROI ........................................................................................................... 330
ENVI_GET_ROI_DATA .............................................................................................. 332
ENVI_GET_ROI_DIMS_PTR ...................................................................................... 334
ENVI_GET_ROI_IDS ................................................................................................... 335
ENVI_GET_ROI_INFORMATION ............................................................................. 337
ENVI_GET_SLICE ....................................................................................................... 339
ENVI_GET_STATISTICS ............................................................................................ 341
ENVI_GET_TILE .......................................................................................................... 344
ENVI_GLT_DOIT ......................................................................................................... 346
ENVI_GRID_DOIT ....................................................................................................... 349
ENVI_GS_SHARPEN_DOIT ....................................................................................... 353
ENVI_INFO_WID ......................................................................................................... 358
ENVI_INIT_TILE ......................................................................................................... 359
ENVI_IO_ERROR ........................................................................................................ 361
ENVI_L7_CPF .............................................................................................................. 362
ENVI_LAYER_STACKING_DOIT ............................................................................. 364
ENVI_MAP_INFO_CREATE ...................................................................................... 370
ENVI_MASK_APPLY_DOIT ...................................................................................... 375
ENVI_NEURAL_NET_DOIT ...................................................................................... 378
ENVI_OPEN_DATA_FILE .......................................................................................... 384
ENVI_OPEN_FILE ....................................................................................................... 390
ENVI_OUTPUT_TO_EXTERNAL_FORMAT ........................................................... 392
ENVI_PC_SHARPEN_DOIT ....................................................................................... 395
ENVI_PICKFILE .......................................................................................................... 398
ENVI_PLOT_DATA ..................................................................................................... 400
Contents

ENVI Reference Guide

ENVI_PROJ_CREATE .................................................................................................
ENVI_QUERY_VERSION ..........................................................................................
ENVI_RADARSAT_GEOREF_DOIT .........................................................................
ENVI_READ_COLS ....................................................................................................
ENVI_REGISTER_DOIT .............................................................................................
ENVI_REPORT_ERROR .............................................................................................
ENVI_REPORT_INC ...................................................................................................
ENVI_REPORT_INIT ..................................................................................................
ENVI_REPORT_STAT ................................................................................................
ENVI_RESAMPLE_SPECTRA ...................................................................................
ENVI_RESTORE_ROIS ...............................................................................................
ENVI_ROI_TO_IMAGE_DOIT ...................................................................................
ENVI_SAVE_ROIS ......................................................................................................
ENVI_SEAWIFS_GEOMETRY_DOIT .......................................................................
ENVI_SEAWIFS_GEOREF_DOIT .............................................................................
ENVI_SEGMENT_DOIT .............................................................................................
ENVI_SELECT .............................................................................................................
ENVI_SENSOR_TYPE ................................................................................................
ENVI_SET_INHERITANCE .......................................................................................
ENVI_SETUP_HEAD ..................................................................................................
ENVI_SMACC_DOIT ..................................................................................................
ENVI_SPECTRAL_RESAMPLING_DOIT ................................................................
ENVI_STATS_DOIT ....................................................................................................
ENVI_SUM_DATA_DOIT ..........................................................................................
ENVI_SYNTHETIC_COLOR_DOIT ..........................................................................
ENVI_THERMAL_CORRECT_DOIT ........................................................................
ENVI_TILE_DONE ......................................................................................................
ENVI_TOGGLE_CATCH ............................................................................................
ENVI_TRANSLATE_PROJECTION_NAME ............................................................
ENVI_TRANSLATE_PROJECTION_UNITS ............................................................
ENVI_USER_DEFINED_ANNOTATION ..................................................................
ENVI_VEG_INDEX_AVAILABLE_INDICES ..........................................................
ENVI_VEG_INDEX_DOIT .........................................................................................
ENVI_WRITE_DBF_FILE ...........................................................................................
ENVI_WRITE_ENVI_FILE .........................................................................................
ENVI_WRITE_FILE_HEADER ..................................................................................
ENVI Reference Guide

403
407
408
412
414
420
422
423
425
427
429
430
433
434
439
444
447
452
455
458
468
474
478
484
488
491
494
495
496
497
498
506
509
512
516
526

Contents

ENVI_WRITE_STATISTICS ....................................................................................... 528


FFT_DOIT ..................................................................................................................... 531
FFT_INV_DOIT ............................................................................................................ 534
GAINOFF_DOIT ........................................................................................................... 538
GEN_IMAGE_DOIT ..................................................................................................... 541
HANDLE_VALUE ........................................................................................................ 544
HIST_EXPORT_DOIT .................................................................................................. 546
MAGIC_MEM_CHECK ............................................................................................... 551
MATCH_FILTER_DOIT .............................................................................................. 553
MATCH_FILTER_MT_DOIT ...................................................................................... 557
MATH_DOIT ................................................................................................................ 561
MNF_DOIT ................................................................................................................... 564
MNF_INV_DOIT .......................................................................................................... 568
MORPH_DOIT .............................................................................................................. 570
MOSAIC_DOIT ............................................................................................................ 574
MSSCAL_DOIT ............................................................................................................ 580
MUNSELL_DOIT ......................................................................................................... 584
MUNSELL_INV_DOIT ................................................................................................ 587
NDVI_DOIT .................................................................................................................. 590
ON_IOERROR .............................................................................................................. 593
PC_ROTATE ................................................................................................................. 594
PPI_DOIT ...................................................................................................................... 598
RADAR_INC_ANGLE_DOIT ...................................................................................... 601
RATIO_DOIT ................................................................................................................ 604
RESIZE_DOIT .............................................................................................................. 607
RGB_GET_BANDS ...................................................................................................... 610
RGB_ITRANS_DOIT ................................................................................................... 612
RGB_TRANS_DOIT ..................................................................................................... 615
ROC_CURVE_DOIT .................................................................................................... 618
ROI_THRESH_DOIT .................................................................................................... 622
ROTATE_DOIT ............................................................................................................ 625
RTV_DOIT .................................................................................................................... 628
SAT_STRETCH_DOIT ................................................................................................. 631
SHARPEN_DOIT .......................................................................................................... 634
SIRC_HEADER_DOIT ................................................................................................. 638
SIRC_MULTILOOK_DOIT ......................................................................................... 641
Contents

ENVI Reference Guide

SIRC_PED_HEIGHT_DOIT ........................................................................................
SIRC_PHASE_IMAGE_DOIT .....................................................................................
SIRC_POLSIG_DOIT ...................................................................................................
SIRC_SYNTH_DOIT ...................................................................................................
SLICE_DOIT ................................................................................................................
SLT2GND_DOIT ..........................................................................................................
SPECTRAL_FEATURE_DOIT ...................................................................................
STRETCH_DOIT ..........................................................................................................
TASCAP_DOIT ............................................................................................................
TEXTURE_COOCCUR_DOIT ....................................................................................
TEXTURE_STATS_DOIT ...........................................................................................
TIMS_CAL_DOIT ........................................................................................................
TMCAL_DOIT .............................................................................................................
TOPO_DOIT .................................................................................................................
TOPO_FEATURE_DOIT .............................................................................................
UNMIX_DOIT ..............................................................................................................
VAX_IEEE_DOIT ........................................................................................................
WIDGET_AUTO_BASE ..............................................................................................
WIDGET_BASE ...........................................................................................................
WIDGET_CONTROL ..................................................................................................
WIDGET_EDIT ............................................................................................................
WIDGET_GEO .............................................................................................................
WIDGET_MAP .............................................................................................................
WIDGET_MENU .........................................................................................................
WIDGET_MULTI .........................................................................................................
WIDGET_OUTF ...........................................................................................................
WIDGET_OUTFM .......................................................................................................
WIDGET_PARAM .......................................................................................................
WIDGET_PMENU .......................................................................................................
WIDGET_RGB .............................................................................................................
WIDGET_SLABEL ......................................................................................................
WIDGET_SLIST ...........................................................................................................
WIDGET_SSLIDER .....................................................................................................
WIDGET_STRING .......................................................................................................

ENVI Reference Guide

645
649
653
657
662
664
668
672
676
679
683
687
690
694
698
703
707
709
711
716
722
726
728
730
733
736
738
740
744
746
748
750
753
757

Contents

10

WIDGET_SUBSET ....................................................................................................... 759


WIDGET_TOGGLE ...................................................................................................... 761

Index .................................................................................................... 763

Contents

ENVI Reference Guide

Chapter 1

Overview
This chapter covers the following topics:

How to Use this Reference Section . . . . . . . 12


Alphabetic List of ENVI Routines . . . . . . . 18

ENVI Reference Guide

Functional List of Basic ENVI Routines . . 33


Quick Reference of ENVI Library Function
Variable Codes . . . . . . . . . . . . . . . . . . . . . . 41

11

12

Chapter 1: Overview

How to Use this Reference Section


All of ENVIs routines are documented alphabetically in this chapter. A description
of each routine follows its name. Beneath the general description of the routine are a
number of sections that describe the syntax for the routine, its arguments (if any), its
keywords (if any), and an example of using the routine. These sections are described
below.

Syntax
The Syntax section shows the proper syntax for calling the function or procedure.
The following table lists the elements used in ENVI and IDL syntax listings:
Element

Description

[ ] (Square brackets)

Indicates that the contents are optional. Do not include the


brackets in your call.

[ ] (Italicized square
brackets)

Indicates that the square brackets are part of the statement


(used to define an array).

Argument

Arguments are shown in italics, and must be specified in


the order listed.

KEYWORD

Keywords are all caps, and can be specified in any order.


For functions, all arguments and keywords must be
contained within parentheses.

/KEYWORD

Indicates a boolean keyword.

Italics

Indicates arguments, expressions, or statements for which


you must provide values.

{ } (Braces)

Indicates that you must choose one of the values they


contain
Encloses a list of possible values, separated by vertical
lines ( | )
Encloses useful information about a keyword
Defines an IDL structure (this is the only case in which
the braces are included in the call).
Table 1-1: Elements of ENVI and IDL Syntax

How to Use this Reference Section

ENVI Reference Guide

Chapter 1: Overview

13

Element

Description

| (Vertical lines)

Separates multiple values or keywords.

[, Value1, ... , Valuen]

Indicates that any number of values can be specified.

[, Value1, ... , Value8]

Indicates the maximum number of values that can be


specified.

Table 1-1: Elements of ENVI and IDL Syntax (Continued)

Elements of Syntax
Square Brackets ( [] )

Content between square brackets is optional. Pay close attention to the


grouping of square brackets. Consider the following examples:
ROUTINE_NAME, Value1 [, Value2] [, Value3]: You must include Value1.
You do not have to include Value2 or Value3. Value2 and Value3 can be
specified independently.
ROUTINE_NAME, Value1 [, Value2, Value3]: You must include Value1. You
do not have to include Value2 or Value3, but you must include both Value2 and
Value3, or neither.
ROUTINE_NAME [, Value1 [, Value2]]: You can specify Value1 without
specifying Value2, but if you specify Value2, you must also specify Value1.

Do not include square brackets in your statement unless the brackets are
italicized. Consider the following syntax:
Result = KRIG2D( Z [, X, Y] [, BOUNDS=[xmin, ymin, xmax, ymax]] )
An example of a valid statement is:
R = KRIG2D( Z, X, Y, BOUNDS=[0,0,1,1] )

Note that when [, Value1, ... , Valuen] is listed, you can specify any number of
arguments. When an explicit number is listed, as in [, Value1, ... , Value8], you
can specify only as many arguments as are listed.

Braces ( {} )

For certain keywords, a list of the possible values is provided. This list is
enclosed in braces, and the choices are separated by a vertical line ( | ). Do not

ENVI Reference Guide

How to Use this Reference Section

14

Chapter 1: Overview

include the braces in your statement. For example, consider the following
syntax:
READ_JPEG [, TRUE={1 | 2 | 3 }]
In this example, you must choose either 1, 2, or 3. An example of a valid
statement is:
READ_JPEG, TRUE=1

Braces are used to enclose the allowable range for a keyword value. Unless
otherwise noted, ranges provided are inclusive. Consider the following syntax:
Result = CVTTOBM( Array [, THRESHOLD=value{0 to 255}] )
An example of a valid statement is:
Result = CVTTOBM( A, THRESHOLD=150 )

Braces are also used to provide useful information about a keyword. For
example:
[, LABEL=n{label every nth gridline}]
Do not include the braces or their content in your statement.

Certain keywords are prefaced by X, Y, or Z. Braces are used for these


keywords to indicate that you must choose one of the values it contains. For
example, [{X | Y}RANGE=array] indicates that you can specify either
XRANGE=array or YRANGE=array.

Note that in ENVI and IDL, braces are used to define structures. When
defining a structure, you do want to include the braces in your statement.

Italics

Italicized words are arguments, expressions, or statements for which you must
provide values. The value you provide can be a numerical value, such as 10, an
expression, such as DIST(100), or a named variable. For keywords that expect
a string value, the syntax is listed as KEYWORD=string. The value you
provide can be a string, such as 'Hello' (enclosed in single quotation marks), or
a variable that holds a string value.

The italicized values that must be provided for keywords are listed in the most
helpful terms possible. For example, [, XSIZE=pixels] indicates that the XSIZE
keyword expects a value in pixels, while
[, ORIENTATION=ccw_degrees_from_horiz] indicates that you must provide
a value in degrees, measured counter-clockwise from horizontal.

How to Use this Reference Section

ENVI Reference Guide

Chapter 1: Overview

15

Procedures
Procedures have the syntax:
PROCEDURE_NAME, Argument [, Optional_Arguments]

where PROCEDURE_NAME is the name of the procedure, Argument is a required


parameter, and Optional_Argument is an optional parameter to the procedure. Note
that the square brackets around optional arguments are not used in the actual call to
the procedure, they are simply used to denote the optional nature of the arguments
within this document.

Functions
Functions have the syntax:
Result = FUNCTION_NAME(Argument [, Optional_Arguments])

where Result is the returned value of the function, FUNCTION_NAME is the name
of the function, Argument is a required parameter, and Optional_Argument is an
optional parameter. Note that the square brackets around optional arguments are not
used in the actual call to the function, they are simply used to denote the optional
nature of the arguments within this document. Note also that all arguments and
keyword arguments to functions should be supplied within the parentheses that
follow the functions name.
Functions do not always have to be used in assignment statements (i.e.,
A=SIN(10.2)), they can be used just like any other IDL expression. For example,
you could print the result of SIN(10.2) by entering the command:
PRINT, SIN(10.2)

Arguments
The Arguments section describes each valid argument to the routine. Note that these
arguments are positional parameters that must be supplied in the order indicated by
the routines syntax.

Named Variables
Often, arguments that contain values upon return from the function or procedure
(output arguments) are described as accepting named variables. A named variable is
simply a valid IDL variable name. This variable does not need to be defined before
being used as an output argument. Note, however that when an argument calls for a
named variable, only a named variable can be usedsending an expression causes an
error.

ENVI Reference Guide

How to Use this Reference Section

16

Chapter 1: Overview

Keywords
The Keywords section describes each valid keyword argument to the routine. Note
that keyword arguments are formal parameters that can be supplied in any order.
Keyword arguments are supplied to ENVI routines by including the keyword name
followed by an equal sign (=) and the value to which the keyword should be set.
For example, to set the filename to ENVI_SETUP_HEAD set the FNAME keyword
to a string containing the desired filename.
ENVI_SETUP_HEAD, FNAME=test.img

Note that keywords can be abbreviated to their shortest unique length. However, this
is not recommended, since the addition of a keyword may make the abbreviation
invalid.

Setting Keywords
When the documentation for a keyword says something similar to, Set this keyword
to enable logarithmic plotting, the keyword is simply a switch that turns an option
on and off. Usually, setting such keywords equal to 1 causes the option to be turned
on. Explicitly setting the keyword to zero (or not including the keyword) turns the
option off.
There is a shortcut that can be used to set a keyword equal to 1 without the usual
syntax (i.e., KEYWORD=1). To set a keyword, simply preface it with a slash
character (/). For example, set the OPEN keyword to ENVI_SETUP_HEAD as
follows:
ENVI_SETUP_HEAD, FNAME=FNAME, /OPEN

Named Variables
Often, keywords that contain values upon return from the function or procedure
(output arguments) are described as accepting named variables. A named variable is
a valid IDL variable name. This variable does not need to be defined before being
used with the keyword. Note, however that when a keyword calls for a named
variable, only a named variable can be usedsending an expression causes an error.
For example, the WIDGET_CONTROL procedure can return the user values of
widgets in a named variable using the GET_UVALUE keyword. To return the user
value for a widget ID (contained in the variable MYWIDGET) in the variable
USERVAL, you would use the command:
WIDGET_CONTROL, mywidget, GET_UVALUE = userval

How to Use this Reference Section

ENVI Reference Guide

Chapter 1: Overview

17

Upon return from the procedure, USERVAL contains the user value. Note that
USERVAL did not have to be defined before the call to WIDGET_CONTROL.

Examples
Most routines have an example that demonstrates how the function or procedure is
used. These code fragments are designed to serve as examples for your own
programs.

See Also
The names of related routines will be listed in this section.

ENVI Reference Guide

How to Use this Reference Section

18

Chapter 1: Overview

Alphabetic List of ENVI Routines


The following is a list of all routines included in ENVI, listed alphabetically.
Routine Name

Description

ADAPT_FILT_DOIT

Perform Adaptive filtering

AIRSAR_HEADER_DOIT

Read AIRSAR Header

AIRSAR_PED_HEIGHT_DOIT

Calculate pedestal height images


from AIRSAR compressed
stoked matrix

AIRSAR_PHASE_IMAGE_DOIT

Calculate phase images from


AIRSAR compressed stokes
matrix

AIRSAR_POLSIG_DOIT

Calculate polarization signatures


from AIRSAR compressed
stokes matrix

AIRSAR_SCATTER_DOIT

Calculate scatter classification


for AIRSAR compressed stokes
matrix

AIRSAR_SYNTH_DOIT

Synthesize AIRSAR images

ASPECT_DOIT

Make aspect corrections to


Landsat MSS image data

AUTO_WID_MNG

Automatically perform event


handling for ENVI compound
widgets

BAD_DATA_DOIT

Remove bad data lines

CATCH

Establish an error handler for the


current procedure

CF_DOIT

Create an output file

CLASS_CONFUSION_DOIT

Compute classification
confusion matrix

Table 1-2: Alphabetic List of ENVI Routines

Alphabetic List of ENVI Routines

ENVI Reference Guide

Chapter 1: Overview

19

Routine Name

Description

CLASS_CS_DOIT

CLUMP and SIEVE a


classification image

CLASS_DOIT

Perform supervised
classification

CLASS_MAJORITY_DOIT

Perform majority or minority


analysis on a classification
image

CLASS_RULE_DOIT

Classify Rule Images

CLASS_STATS_DOIT

Calculate class statistics

COM_CLASS_DOIT

Combine Classes

CONTINUUM_REMOVE_DOIT

Perform continuum removal

CONV_DOIT

Perform convolution filtering

CONVERT_DOIT

Convert interleave type (BSQ,


BIL, BIP)

CONVERT_INPLACE_DOIT

Convert in place between storage


types

CROSS_TRACK_CORRECTION_DOIT

Remove variation in the crosstrack illumination of an image

DARK_SUB_DOIT

Perform Dark Subtraction

DECOR_DOIT

Perform Saturation Stretch

DEM_BAD_DATA_DOIT

Correct bad data points in DEMs

DESKEW_DOIT

Deskew MSS

DESTRIPE_DOIT

Destripe image data

DISP_GET_LOCATION

Get x and y pixel locations in a


display

DISP_GOTO

Move the current pixel in a


display

Table 1-2: Alphabetic List of ENVI Routines (Continued)

ENVI Reference Guide

Alphabetic List of ENVI Routines

20

Chapter 1: Overview

Routine Name

Description

DISP_OUT_IMG

Output to Postscript

ELINE_CAL_DOIT

Perform Empirical Line


Calibration

EMITTANCE_CALC_DOIT

Convert emissivity

ENVI

Restore base ENVI Save files for


Batch mode.

ENVI_ADD_PROJECTION

Add a projection to ENVI

ENVI_ASSIGN_HEADER_VALUE

Set user defined header values

ENVI_AUTO_TIE_POINTS_DOIT

Automatically calculates tie


points for two images, making
fully automatic image
registration possible

ENVI_AVHRR_CALIBRATE_DOIT

Calibrate AVHRR data or


compute AVHRR Sea Surface
Temperature (SST)

ENVI_AVHRR_GEOMETRY_DOIT

Compute the AVHRR geometry


(latitude and longitude), solar
zenith angles, and sensor zenith
angles for each pixel

ENVI_AVHRR_WARP_DOIT

Warp AVHRR data or resulting


AVHRR data products

ENVI_BANDMAX_SELECT_BANDS

Perform the BandMax


background suppression
algorithm to derive a subset of
significant bands using input
target and background spectra

ENVI_BATCH_EXIT

Exit ENVI from the non-menu


batch mode

ENVI_BATCH_INIT

Initialize ENVI in the non-menu


batch mode

Table 1-2: Alphabetic List of ENVI Routines (Continued)

Alphabetic List of ENVI Routines

ENVI Reference Guide

Chapter 1: Overview

21

Routine Name

Description

ENVI_BATCH_STATUS_WINDOW

Enable and disable the ENVI


batch status window

ENVI_BUFFER_ZONE_DOIT

Create a buffer zone image from


a classification image

ENVI_CAL_DOIT

Spectrally calibrate images using


Flat Field or IARR

ENVI_CENTER

Return the centering offsets for a


widget

ENVI_CLOSE_DISPLAY

Closes an ENVI display group

ENVI_CLOVER_DOIT

Overlay Classes

ENVI_COLLECT_SPECTRA

Perform endmember collection

ENVI_COMPUTE_SUN_ANGLES

Compute sun angles

ENVI_CONVERT_FILE_COORDINATES

Convert between map and pixel


coordinates

ENVI_CONVERT_FILE_MAP_PROJECTION Convert a file from its current


map projection to specified
output projection
ENVI_CONVERT_LIDAR_DATA_DOIT

Read in a LAS standard


formatted LIDAR data file and
convert it to either an ENVI
image file or an EVF file

ENVI_CONVERT_PROJECTION_COORDIN
ATES

Convert map coordinates


between projections

ENVI_CREATE_ROI

Create a new ROI

ENVI_CUBE_3D_DOIT

Build a 3D Image Cube

ENVI_DEFAULT_STRETCH_CREATE

Return an ENVI default stretch


structure

Table 1-2: Alphabetic List of ENVI Routines (Continued)

ENVI Reference Guide

Alphabetic List of ENVI Routines

22

Chapter 1: Overview

Routine Name

Description

ENVI_DEFINE_MENU_BUTTON

Add buttons to the ENVI menu


system automatically from a
user-defined routine in a .pro or
.sav file within the save_add
directory

ENVI_DEFINE_ROI

Add objects to an ROI

ENVI_DELETE_ROIS

Delete ROIs

ENVI_DISP_QUERY

Get display information

ENVI_DISPLAY_BANDS

Display grayscale or RGB image


in a display window

ENVI_DOIT

Interface for all of the ENVI


processing routines (the _DOIT
routines)

ENVI_ENTER_DATA

Enter image data into ENVI

ENVI_ENVISAT_GEOREF_DOIT

Georeference AATSR, ASAR,


and MERIS format ENVISAT
data

ENVI_EVF_CLOSE

Close an ENVI Vector File


(EVF)

ENVI_EVF_DEFINE_ADD_RECORD

Add a record to a new ENVI


Vector File (EVF)

ENVI_EVF_DEFINE_CLOSE

Close a new ENVI Vector File


(EVF)

ENVI_EVF_DEFINE_INIT

Initialize a new ENVI Vector


File (EVF)

ENVI_EVF_INFO

Get general information about an


ENVI Vector File (EVF)

ENVI_EVF_OPEN

Open an existing ENVI Vector


File (EVF)

Table 1-2: Alphabetic List of ENVI Routines (Continued)

Alphabetic List of ENVI Routines

ENVI Reference Guide

Chapter 1: Overview

23

Routine Name

Description

ENVI_EVF_READ_RECORD

Retrieve records from an ENVI


Vector File (EVF)

ENVI_EVF_TO_SHAPEFILE

Creates output of ENVI vector


files (EVF) to ArcView shapefile
formats

ENVI_FILE_MNG

Remove and delete ENVI files

ENVI_FILE_QUERY

Get information on ENVI files

ENVI_FILE_TYPE

File type description

ENVI_FILTER_DOIT

FFT Filter Building

ENVI_GEOREF_FROM_GLT_DOIT

Georeference an associated
image with the GLT file output
from GLT_DOIT.

ENVI_GET_CONFIGURATION_VALUES

Get current setting for ENVI


configuration items

ENVI_GET_DATA

Get spatial image data from a file

ENVI_GET_DISPLAY_NUMBERS

Get a list of display numbers

ENVI_GET_FILE_IDS

Get file ids for all open files

ENVI_GET_HEADER_VALUE

Retrieve user defined values

ENVI_GET_IMAGE

Get spatial image data from a


display

ENVI_GET_MAP_INFO

Get map information from a


display

ENVI_GET_PATH

Returns the path where the


current version of ENVI is
installed

ENVI_GET_PROJECTION

Get the projection information


for the specified file, display, or
map information handle

Table 1-2: Alphabetic List of ENVI Routines (Continued)

ENVI Reference Guide

Alphabetic List of ENVI Routines

24

Chapter 1: Overview

Routine Name

Description

ENVI_GET_RGB_TRIPLETS

Get RGB triplets for graphics


color index

ENVI_GET_ROI

Get ROI addresses

ENVI_GET_ROI_DATA

Get the data associated with an


ROI

ENVI_GET_ROI_DIMS_PTR

Get DIMS pointer from ROI IDs

ENVI_GET_ROI_IDS

Get ROI IDs

ENVI_GET_ROI_INFORMATION

Get information associated with


defined ROIs.

ENVI_GET_SLICE

Get spectral slice of data from a


file

ENVI_GET_STATISTICS

Get values from an ENVI


statistics file

ENVI_GET_TILE

Get tile data

ENVI_GLT_DOIT

Build a Geographic Lookup


Table (GLT) file from input
geometry.

ENVI_GRID_DOIT

Convert irregularly gridded


points to raster image

ENVI_GS_SHARPEN_DOIT

Perform Gram-Schmidt spectral


sharpening.

ENVI_INFO_WID

Display text data in widget

ENVI_INIT_TILE

Initialize the tile processing

ENVI_IO_ERROR

Report Input/Output processing


errors

ENVI_L7_CPF

Retrieve Landsat 7 calibration


parameters from an RSI Web
server.

Table 1-2: Alphabetic List of ENVI Routines (Continued)

Alphabetic List of ENVI Routines

ENVI Reference Guide

Chapter 1: Overview

25

Routine Name

Description

ENVI_LAYER_STACKING_DOIT

Build a new multiband file from


georeferenced images of various
pixel sizes, extents, and
projections

ENVI_MAP_INFO_CREATE

Create map projections

ENVI_MASK_APPLY_DOIT

Apply a mask to a file

ENVI_NEURAL_NET_DOIT

Perform classification using a


Neural Net method

ENVI_OPEN_DATA_FILE

Open a data file

ENVI_OPEN_FILE

Open an ENVI file

ENVI_OUTPUT_TO_EXTERNAL_FORMAT

Output image data to external


formats

ENVI_PC_SHARPEN_DOIT

Perform Principal Components


spectral sharpening.

ENVI_PICKFILE

Pick a filename

ENVI_PLOT_DATA

Create an x,y plot

ENVI_PROJ_CREATE

Create an ENVI projection


structure

ENVI_QUERY_VERSION

Return the current version of


ENVI

ENVI_RADARSAT_GEOREF_DOIT

Extracts embedded geolocation


points from a processed
RADARSAT file

ENVI_READ_COLS

Read ASCII column data

ENVI_REGISTER_DOIT

Warps image data

ENVI_REPORT_ERROR

Report error message strings


through the standard ENVI error
reporting mechanism.

Table 1-2: Alphabetic List of ENVI Routines (Continued)

ENVI Reference Guide

Alphabetic List of ENVI Routines

26

Chapter 1: Overview

Routine Name

Description

ENVI_REPORT_INC

Set the status report increment

ENVI_REPORT_INIT

Initialize the status report

ENVI_REPORT_STAT

Update status report percent


complete

ENVI_RESAMPLE_SPECTRA

Spectrally resample individual


spectra.

ENVI_RESTORE_ROIS

Restore saved ROI files

ENVI_ROI_TO_IMAGE_DOIT

Create a classification image


from ROIs

ENVI_SAVE_ROIS

Save ROIs

ENVI_SEAWIFS_GEOMETRY_DOIT

Calculate the geometry for HDF


and CEOS format SeaWiFS data

ENVI_SEAWIFS_GEOREF_DOIT

Georeferences HDF and CEOS


format SeaWiFS data

ENVI_SEGMENT_DOIT

Segment a classification image


into unique spatially contiguous
blobs

ENVI_SELECT

Select an open ENVI file or band

ENVI_SENSOR_TYPE

Return sensor type description

ENVI_SET_INHERITANCE

Return the ENVI inheritance


structure

ENVI_SETUP_HEAD

Set and write ENVI header


information

ENVI_SMACC_DOIT

Perform sequential maximum


angle convex cone (SMACC)
processing on an input file

ENVI_SPECTRAL_RESAMPLING_DOIT

Spectrally resample image or


spectral library files.

Table 1-2: Alphabetic List of ENVI Routines (Continued)

Alphabetic List of ENVI Routines

ENVI Reference Guide

Chapter 1: Overview

27

Routine Name

Description

ENVI_STATS_DOIT

Calculate statistics of a data file

ENVI_SUM_DATA_DOIT

Calculate a number of statistical


parameters on a set of bands

ENVI_SYNTHETIC_COLOR_DOIT

Calculate synthetic color image

ENVI_THERMAL_CORRECT_DOIT

Perform thermal infrared


atmospheric compensation.

ENVI_TILE_DONE

Complete tile processing

ENVI_TOGGLE_CATCH

Toggle the ENVI error catching


handling mechanism on and off

ENVI_TRANSLATE_PROJECTION_NAME

Convert projection names

ENVI_TRANSLATE_PROJECTION_UNITS

Translate projection units

ENVI_USER_DEFINED_ANNOTATION

Create an ENVI annotation file


or append items to an existing
annotation file

ENVI_VEG_INDEX_AVAILABLE_INDICES

Determines the number of


vegetation indices that can be
calculated on an input data file

ENVI_VEG_INDEX_DOIT

Calculates vegetation indices


from a spectral input image

ENVI_WRITE_DBF_FILE

Write a DBF attribute file for an


ENVI Vector File (EVF)

ENVI_WRITE_ENVI_FILE

Convert an IDL image array to


an ENVI image

ENVI_WRITE_FILE_HEADER

Write/re-write an ENVI header


file to preserve changes to user
defined header values.

ENVI_WRITE_STATISTICS

Write an ENVI statistics file

FFT_DOIT

Perform Fast Fourier Transform


(FFT) filtering

Table 1-2: Alphabetic List of ENVI Routines (Continued)


ENVI Reference Guide

Alphabetic List of ENVI Routines

28

Chapter 1: Overview

Routine Name

Description

FFT_INV_DOIT

Apply FFT filter and perform


inverse FFT

GAINOFF_DOIT

Apply Gain and Offset to each


input band

GEN_IMAGE_DOIT

Generate test images

HANDLE_VALUE

Get and set handle values

HIST_EXPORT_DOIT

Output images using applied


Lookup Table (LUT)

MAGIC_MEM_CHECK

Clear out the necessary memory


cache for in-memory functions

MATCH_FILTER_DOIT

Perform Matched Filtering

MATCH_FILTER_MT_DOIT

Perform Mixture-Tuned
Matched Filtering (MTMF)

MATH_DOIT

Perform Band Math

MNF_DOIT

Perform Minimum Noise


Fraction (MNF) transform

MNF_INV_DOIT

Perform inverse MNF transform

MORPH_DOIT

Perform morphological filtering

MOSAIC_DOIT

Mosaic image bands or band


combinations

MSSCAL_DOIT

Calibrate MSS data to radiance


or reflectance

MUNSELL_DOIT

Convert RGB image to Munsell


coordinates

MUNSELL_INV_DOIT

Calculate RGB image from


Munsell coordinates

NDVI_DOIT

Create Normalized Difference


Vegetation Index (NDVI)

Table 1-2: Alphabetic List of ENVI Routines (Continued)

Alphabetic List of ENVI Routines

ENVI Reference Guide

Chapter 1: Overview

29

Routine Name

Description

ON_IOERROR

Specifies a statement to be
jumped to if an Input/Output
error occurs in the current
procedure

PC_ROTATE

Calculate Principal Components


Rotation

PPI_DOIT

Calculate Pixel Purity Index


(PPI)

RADAR_INC_ANGLE_DOIT

Calculate incidence angle image


from radar

RATIO_DOIT

Calculate Band Ratios

RESIZE_DOIT

Spatially resize data

RGB_GET_BANDS

Display a dialog for selecting


three bands from the Available
Bands List

RGB_ITRANS_DOIT

Perform inverse color transform

RGB_TRANS_DOIT

Perform forward color transform

ROC_CURVE_DOIT

Compute Receiver Operating


Characteristic (ROC) curves

ROI_THRESH_DOIT

Threshold ROI (Region of


Interest)

ROTATE_DOIT

Rotate images

RTV_DOIT

Perform raster to vector


conversion

SAT_STRETCH_DOIT

Perform Saturation Stretch

SHARPEN_DOIT

Perform Image Sharpening

SIRC_HEADER_DOIT

Read SIR-C Header

SIRC_MULTILOOK_DOIT

Multilook SIR-C Images

Table 1-2: Alphabetic List of ENVI Routines (Continued)

ENVI Reference Guide

Alphabetic List of ENVI Routines

30

Chapter 1: Overview

Routine Name

Description

SIRC_PED_HEIGHT_DOIT

Calculate pedestal height images


from a SIR-C compressed data
products file

SIRC_PHASE_IMAGE_DOIT

Calculate phase images from a


SIR-C compressed data products
file

SIRC_POLSIG_DOIT

Calculate polarization signatures


from a SIR-C compressed data
products file

SIRC_SYNTH_DOIT

Synthesize SIR-C Images

SLICE_DOIT

Extract a spectral slice

SLT2GND_DOIT

Convert slant to ground range

SPECTRAL_FEATURE_DOIT

Perform Spectral Feature Fitting

STRETCH_DOIT

Perform Contrast Stretch of


image data

TASCAP_DOIT

Create Tasseled Cap vegetation


and soil indices

TEXTURE_COOCCUR_DOIT

Calculate Co-occurrence Texture


Measures

TEXTURE_STATS_DOIT

Calculate Occurrence Texture


Measures

TIMS_CAL_DOIT

Calibrate TIMS data to radiance

TMCAL_DOIT

Calibrate Landsat TM data to


radiance or reflectance

TOPO_DOIT

Perform Topographic Modeling


of DEMs

TOPO_FEATURE_DOIT

Create a topographic feature


classification image

Table 1-2: Alphabetic List of ENVI Routines (Continued)

Alphabetic List of ENVI Routines

ENVI Reference Guide

Chapter 1: Overview

31

Routine Name

Description

UNMIX_DOIT

Perform Linear Spectral


Unmixing

VAX_IEEE_DOIT

Perform VAX IEEE Floating


Point Conversion

WIDGET_AUTO_BASE

Create top level base for automanaged widgets

WIDGET_BASE

Create a base widget

WIDGET_CONTROL

Realize, manage, and destroy


widgets

WIDGET_EDIT

Return the base ID of the edit list


widget

WIDGET_GEO

Return the base ID of the


latitude/longitude specification
widget

WIDGET_MAP

Return the base ID of the map


information input/edit widget

WIDGET_MENU

Return the base ID of the menu


widget

WIDGET_MULTI

Return the base ID of the


multiple list selection widget

WIDGET_OUTF

Return the base ID of the output


filename selection widget

WIDGET_OUTFM

Return the base ID of the output


filename or memory selection
widget

WIDGET_PARAM

Return the base ID of the


parameter input widget

WIDGET_PMENU

Return the base ID of the


pulldown menu widget

Table 1-2: Alphabetic List of ENVI Routines (Continued)

ENVI Reference Guide

Alphabetic List of ENVI Routines

32

Chapter 1: Overview

Routine Name

Description

WIDGET_RGB

Return the base ID of the color


value editing widget

WIDGET_SLABEL

Return the base ID of the display


string widget

WIDGET_SLIST

Return the base ID of the list


widget

WIDGET_SSLIDER

Return the base ID of the slider


widget

WIDGET_STRING

Return the base ID of the string


entry widget

WIDGET_SUBSET

Return the base ID of the image


subset widget

WIDGET_TOGGLE

Return the base ID of the arrow


toggle selection widget

Table 1-2: Alphabetic List of ENVI Routines (Continued)


Note
All of the batch processing function examples assume that the core ENVI save files
have been restored. For more information on restoring the core ENVI save files see
Batch Mode ENVI in Chapter 3 of the ENVI Programmers Guide manual.

Alphabetic List of ENVI Routines

ENVI Reference Guide

Chapter 1: Overview

33

Functional List of Basic ENVI Routines


The following is a list of the most commonly used routines included in ENVI,
categorized by functionality.

Batch Mode
Routine Name

Usage

ENVI

Restores core ENVI save files when used


with the RESTORE_BASE_SAVE_FILES
keyword

ENVI_BATCH_EXIT

Exits a batch mode session

ENVI_BATCH_INIT

Initiates a batch mode session

ENVI_BATCH_STATUS_WINDOW Enable and disable the batch status


window
Table 1-3: Batch Mode Routines

File Input and Management


Routine Name

Usage

ENVI_GET_PATH

Returns the path where the current version


of ENVI is installed

ENVI_FILE_MNG

Closes and/or deletes files

ENVI_GET_FILE_IDS

Returns all opened file IDs

ENVI_OPEN_DATA_FILE

Opens external (non-ENVI) image files

ENVI_OPEN_FILE

Opens a file from disk

ENVI_PICKFILE

Widget for selecting a filename from disk

Table 1-4: File Input and Management Routines

ENVI Reference Guide

Functional List of Basic ENVI Routines

34

Chapter 1: Overview

Routine Name
ENVI_SELECT

Usage
Widget for choosing an opened file

Table 1-4: File Input and Management Routines (Continued)

File Information
Routine Name

Usage

ENVI_FILE_QUERY

Returns info from an ENVI header file

ENVI_FILE_TYPE

Translates between file type codes and


descriptions

ENVI_SENSOR_TYPE

Translates between sensor type codes and


descriptions

ENVI_SET_INHERITANCE

Return the ENVI inheritance structure

Table 1-5: File Information Routines

File Output
Routine Name

Usage

CF_DOIT

Creates a new ENVI image from existing


FIDs

ENVI_ENTER_DATA

Enters an image into memory as an ENVI


file

ENVI_OUTPUT_TO_
EXTERNAL_FORMAT

Outputs a file to an non-ENVI (external)


format

ENVI_SETUP_HEAD

Writes an ENVI header file for an image


file
Table 1-6: File Output Routines

Functional List of Basic ENVI Routines

ENVI Reference Guide

Chapter 1: Overview

35

Routine Name
SLICE_DOIT

Usage
Outputs a vertical or horizontal data slice
to file

Table 1-6: File Output Routines (Continued)

Reading Image Data (Non-Tiled)


Routine Name

Usage

ENVI_GET_DATA

Returns spatial image data from file

ENVI_GET_IMAGE

Returns stretched data from a display


window

ENVI_GET_SLICE

Returns spectral image data from file

Table 1-7: Reading Image Data (Non-Tiled) Routines

ROI Processing
Routine Name

Usage

ENVI_CREATE_ROI

Returns a new ROI ID

ENVI_DEFINE_ROI

Adds pixels to an ROI

ENVI_DELETE_ROIS

Deletes ROI from the ENVI session

ENVI_GET_ROI

Returns ROI pixel addresses as 1-D


subscripts

ENVI_GET_ROI_DATA

Returns image data associated with an ROI

ENVI_GET_ROI_DIMS_PTR

Returns ROI pointer for use with DIMS


variable

ENVI_GET_ROI_IDS

Returns available ROI Ids

Table 1-8: ROI Processing Routines

ENVI Reference Guide

Functional List of Basic ENVI Routines

36

Chapter 1: Overview

Routine Name

Usage

ENVI_RESTORE_ROIS

Restores ROIs from file

ENVI_SAVE_ROIS

Saves ROIs to disk

Table 1-8: ROI Processing Routines (Continued)

Tiling
Routine Name

Usage

ENVI_GET_TILE

Returns one spatial or spectral tile of image


data

ENVI_INIT_TILE

Initiates tiled processing and returns the


tile ID

ENVI_TILE_DONE

Ends tiled processing


Table 1-9: Tiling Routines

Reporting
Routine Name

Usage

ENVI_REPORT_INC

Computes the status reporting increment

ENVI_REPORT_INIT

Both initializes and ends status reporting

ENVI_REPORT_STAT

Updates the status reporting widget dialog


Table 1-10: Reporting Routines

Functional List of Basic ENVI Routines

ENVI Reference Guide

Chapter 1: Overview

37

Map Information
Routine Name

Usage

ENVI_AUTO_TIE_POINTS

Automatically calculates tie points for two


images, making fully automatic image
registration possible

ENVI_ADD_PROJECTION

Adds a new projection to the ENVI session

ENVI_CONVERT_FILE_
COORDINATES

Converts between file and map coordinates

ENVI_CONVERT_FILE_MAP_
PROJECTION

Converts a georeferenced file into a new


projection

ENVI_CONVERT_
PROJECTION_
COORDINATES

Converts coordinates between map


projections

ENVI_GET_PROJECTION

Returns an ENVI_PROJ_STRUCT
variable

ENVI_MAP_INFO_CREATE

Creates a new ENVI_MAP_STRUCT


variable

ENVI_PROJ_CREATE

Builds a projections
ENVI_PROJ_STRUCT

ENVI_RADARSAT_GEOREF_
DOIT

Extracts embedded geolocation points


from a processed RADARSAT file

ENVI_TRANSLATE_
PROJECTION_NAME

Translates between projection type codes


& names

ENVI_TRANSLATE_
PROJECTION_UNITS

Translates between projection unit codes &


names

Table 1-11: Map Information Routines

ENVI Reference Guide

Functional List of Basic ENVI Routines

38

Chapter 1: Overview

Widgets
Routine Name

Usage

AUTO_WID_MNG

Returns user-inputted info from an ENVI


GUI

ENVI_CENTER

Returns centering offsets for widget


positioning

ENVI_COLLECT_
SPECTRA

ENVIs Endmember Collection dialog

ENVI_DEFINE_MENU_BUTTON

Adds buttons to the ENVI menu system


automatically from a user-defined routine
in a .pro or .sav file within the
save_add directory

ENVI_INFO_WID

Displays text in a non-modal report


widget

ENVI_PICKFILE

ENVIs standard pickfile widget

ENVI_SELECT

ENVIs standard file selection dialog

RGB_GET_BANDS

ENVIs Available Bands List dialog

WIDGET_AUTO_BASE

Creates a widget base for auto-managed


events

WIDGET_EDIT

Widget for editing items from a list

WIDGET_GEO

Widget for entering lat/lon data

WIDGET_MAP

Widget for editing map information

WIDGET_MENU

Widget for making radio and checkmark


buttons

WIDGET_MULTI

Widget for selecting multiple items from a


list

WIDGET_OUTF

Widget for saving a file to disk


Table 1-12: Widget Routines

Functional List of Basic ENVI Routines

ENVI Reference Guide

Chapter 1: Overview

39

Routine Name

Usage

WIDGET_OUTFM

Widget for saving a file to memory or disk

WIDGET_PARAM

Widget for entering a numeric parameter

WIDGET_PMENU

Widget for making a pull-down menu

WIDGET_RGB

Widget for editing color values

WIDGET_SLABEL

Widget with scroll bars for displaying text

WIDGET_SLIST

Widget for creating items in a list

WIDGET_SSLIDER

Widget for defining a value with a slider

WIDGET_STRING

Widget for entering a string

WIDGET_SUBSET

ENVIs standard Spatial Subset widgets

WIDGET_TOGGLE

Creates an ENVI toggle button

Table 1-12: Widget Routines (Continued)

Image Displays
Routine Name

Usage

DISP_GET_LOCATION

Returns the position of the selected pixel

DISP_GOTO

Moves the cursor to a specified location

ENVI_CLOSE_DISPLAY

Closes an ENVI display group

ENVI_DISP_QUERY

Returns display information

ENVI_DISPLAY_BANDS

Creates an ENVI Image Display Group

ENVI_GET_DISPLAY_NUMBERS

Returns all available ENVI display


numbers

ENVI_GET_IMAGE

Returns stretched data from a display


window
Table 1-13: Image Display Routines

ENVI Reference Guide

Functional List of Basic ENVI Routines

40

Chapter 1: Overview

Vector Processing
Routine Name

Usage

ENVI_EVF_CLOSE

Closes an EVF file

ENVI_EVF_DEFINE_
ADD_RECORD

Adds records to an EVF file

ENVI_EVF_DEFINE_CLOSE

Closes an EVF ID for editing

ENVI_EVF_DEFINE_INIT

Creates a new EVF ID

ENVI_EVF_INFO

Returns info about an EVF file

ENVI_EVF_OPEN

Opens an EVF file and returns an EVF ID

ENVI_EVF_READ_RECORD

Reads EVF records into an IDL variable

ENVI_EVF_TO_SHAPEFILE

Creates output of ENVI vector files (EVF)


to ArcView shapefile formats

ENVI_WRITE_DBF_FILE

Writes an EVF attribute file in DBF format

Table 1-14: Vector Processing Routines

Functional List of Basic ENVI Routines

ENVI Reference Guide

Chapter 1: Overview

41

Quick Reference of ENVI Library Function


Variable Codes
Many of the ENVI library routines use integer values (or codes) to define the state of
variables, data, or images. These codes are often encountered in routines such as
ENVI_FILE_QUERY, ENVI_SETUP_HEAD, ENVI_INIT_TILE, and
ENVI_PROJ_CREATE, although their definitions are the same in all library routines.
The following tables provides a quick reference of the codes for many of the most
commonly used variables, including the projection type code and data required for
defining a new projection in batch mode.

Data Type
Type Code

Definition

byte

short integer (2 bytes)

long integer (4 bytes)

floating point

double precision floating point

complex floating point

12

unsigned short integer

13

unsigned long integer

14

64-bit signed integer

15

64-bit unsigned integer


Table 1-15: Data Type Variable Codes

ENVI Reference Guide

Quick Reference of ENVI Library Function Variable Codes

42

Chapter 1: Overview

Interleave
Type Code

Definition

BSQ

BIL

BIP
Table 1-16: Interleave Variable Codes

Default Stretch
Type Code

Definition

no stretch

percent linear

linear range

gaussian

equalize

square foot
Table 1-17: Default Stretch Variable Codes

Byte Swap
Type Code

Definition

data file is same byte order as the current processor

data file is different byte order than the current


processor
Table 1-18: Byte Swap Variable Codes

Quick Reference of ENVI Library Function Variable Codes

ENVI Reference Guide

Chapter 1: Overview

43

Projection Units
Type Code

Definition

meters

km

feet

yards

miles

nautical miles

degrees

minutes

seconds

radians

10

acres

11

hectares

others

Use ENVI_TRANSLATE_PROJECTION_UNITS
Table 1-19: Projection Units Variable Codes

Projection Type
Type Code

Definition

Arbitrary [no parameters required]

Geographic lat/lon [no parameters required]

UTM [zone number]

Transverse Mercator [a, b, lat0, lon0, x0, y0, k0,]


Table 1-20: Projection Types Variable Codes

ENVI Reference Guide

Quick Reference of ENVI Library Function Variable Codes

44

Chapter 1: Overview

Type Code

Definition

Lambert Conformal Conic [a, b, lat0, lon0, x0, y0,


sp1, sp2]

Hotine Oblique Mercator A [a, b, lat0, lat1, lon1,


lat2, lon2, x0, y0, k0]

Hotine Oblique Mercator B [a, b, lat0, lon0,


azimuth, x0, y0, k0]

Stereographic (ellipsoid) [a, b, lat0, lon0, x0, y0, k0]

State Plane [zone number]

Albers Conical Equal Area [a, b, lat0, lon0, x0, y0,


sp1, sp2]

10

Polyconic [a, b, lat0, lon0, x0, y0]

11

Lambert Azimuthal Equal Area [a, b, lat0, lon0, x0,


y0]

12

Azimuthal Equidistant [r, lat0, lon0, x0, y0]

13

Gnomonic [r, lat0, lon0, x0, y0,]

14

Orthographic [r, lat0, lon0, x0, y0]

15

General Vertical Nearside Perspective [r, lat0, lon0,


x0, y0, height]

16

Sinusoidal [r, lon0, x0, y0]

17

Equirectangular [r, lat0, lon0, x0, y0]

18

Miller Cylindrical [r, lon0, x0, y0]

19

Van der Griten [r, lat0, lon0, x0, y0]

20

Mercator [a, b, lat0, lon0, x0, y0]

21

Robinson [r, lon0, x0, y0]

22

Space Oblique Mercator A [a, b, sat num, path num,


path flag, x0, y0]

23

Alaska Conformal [a, b, x0, y0]

Table 1-20: Projection Types Variable Codes (Continued)


Quick Reference of ENVI Library Function Variable Codes

ENVI Reference Guide

Chapter 1: Overview

45

Type Code

Definition

24

Interrupted Goode [r]

25

Mollweide [, lon0, x0, y0]

26

Interrupted Mollweide [r]

27

Hammer [r, lon0, x0, y0]

28

Wagner IV [r, lon0, x0, y0]

29

Wagner VII [r, lon0, x0, y0]

30

Oblated Equal Area [r, lat0, lon0, x0, y0, shapem,


shapen, angle]

31

Polar Stereographic [a, b, lat0, lon0, x0, y0]

32

Space Oblique Mercator B [a, b, sat num, path num,


x0, y0]

33

Equidistant Conic A [a, b, lat0, lon0, x0, y0, sp1]

34

Equidistant Conic B [a, b, lat0, lon0, x0, y0, sp1,


sp2]

35

Stereographic (sphere) [r, lat0, lon0, x0, y0]

36

Lambert Azimuthal Equal Area (sphere) [r, lat0,


lon0, x0, y0]

37

Space Oblique Mercator A [a, b, IncAng, AscLong,


x0, y0, PsRev, LRat

38

Integerized Sinusoidal [r, lon0,x0, y0,Dzone,


Djustify

99

User Defined [a, b, lat0, lon0, x0, y0, [additional


parameters] ]

Table 1-20: Projection Types Variable Codes (Continued)

ENVI Reference Guide

Quick Reference of ENVI Library Function Variable Codes

Chapter 2

ENVI Routines
This chapter describes the ENVI routines, in alphabetical order.

ENVI Reference Guide

46

Chapter 2: ENVI Routines

47

ADAPT_FILT_DOIT
Use this program to perform adaptive filtering including Lee filter, localized sigma
filter and bit error removal.

Syntax
ENVI_DOIT, ADAPT_FILT_DOIT

Keywords
ADD_MEAN
Use this keyword to specify a variable that will contain the additive noise mean.
ADD_MEAN is a floating point number. This value is only used for the LEE filter,
METHOD 0, and NOISE_TYPE 2.

DAMP
Use this keyword to specify the filter damping factor. DAMP is a floating point
number greater than or equal to zero. If DAMP is set to zero the filter performs like
an averaging filter. This value is only used for the Frost filter, METHOD 3.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

ENVI Reference Guide

ADAPT_FILT_DOIT

48

Chapter 2: ENVI Routines

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

KX
Use this keyword to specify a square kernel size. KX is an integer number greater
than or equal to three.

METHOD
Use this keyword to specify the type of filter. Choose one of the following:

0 - LEE

1 - Bit Error Removal

2 - Localized Sigma

3 - Frost

4 - Gamma

5 - Kuan

6 - Enhanced Lee

7 - Enhanced Frost

MULT_MEAN
Use this keyword to specify a variable that will contain the multiplicative noise mean.
MULT_MEAN is a floating point number. This value is only used for the LEE filter,
METHOD 0 and NOISE_TYPE 1 and 2.

NLOOK
Use this keyword to specify a variable that will contain the number of looks for the
data. NLOOK is an integer number. This value is only used for the GAMMA and
KUAN filters, METHOD 4 and 5 respectively.

ADAPT_FILT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

49

NOISE_TYPE
Use this keyword to specify a variable that will contain the type of noise to filter. The
two types of noise are multiplicative noise and additive noise. NOISE_TYPE is an
integer value ranging from 0 to 2.

0 - Additive noise

1 - Multiplicative noise

2 - Both additive and multiplicative

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

REPLACE
Set this keyword to 1 to replace bit errors with the local average. Otherwise, set this
keyword to zero. This keyword is only used for method 1.

SIGMA
Use this keyword to specify Sigma for method 0 or the Sigma Factor for methods 1
and 2.

TOL
Use this keyword to specify the maximum standard deviation tolerance. This
keyword is only used for method 1.

ENVI Reference Guide

ADAPT_FILT_DOIT

50

Chapter 2: ENVI Routines

VMAX
Use this keyword to specify the maximum value for valid data. This keyword is only
used for method 1.

VMIN
Use this keyword to specify the minimum value for valid data. This keyword is only
used for method 1.

Example
pro example_adapt_filt_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bonnrsat.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the necessary variables
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
kx = 5
sigma = .5
method = 0
mult_mean = 1.
noise_type = 1
out_name = testimg
;
; Call the "doit"
;
envi_doit, adapt_filt_doit, fid=fid, pos=pos, $
dims=dims, out_name=out_name, kx=kx, sigma=sigma, $

ADAPT_FILT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

51

noise_type=noise_type, mult_mean=mult_mean, $
method=method, in_memory=0
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

ADAPT_FILT_DOIT

52

Chapter 2: ENVI Routines

AIRSAR_HEADER_DOIT
Use this function to read the AIRSAR header information used by other AIRSAR
routines. The function returns one if the specified file is an AIRSAR file. Otherwise,
zero is returned. The desired AIRSAR information is returned using optional
keywords.

Syntax
ENVI_DOIT, AIRSAR_HEADER_DOIT

Keywords
BAND (optional)
Use this keyword to specify a named variable that will contain the band number for
the file specified by Filename. BAND is set to 0, 1, or 2 to specify C, L, or P
respectively.

FILENAME
Set this keyword to specify the filename of the AIRSAR file.

GENFAC (optional)
Use this optional keyword to specify a named variable that will contain the COMP
SCALE FACTOR for the band.

NAME
Use this keyword to specify an AIRSAR file name.

NL (optional)
Use this optional keyword to specify a named variable that will contain the number of
lines in the AIRSAR image.

NS (optional)
Use this optional keyword to specify a named variable that will contain the number of
samples per line in the AIRSAR image.

AIRSAR_HEADER_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

53

OFFSET (optional)
Use this optional keyword to specify a named variable that will contain the offset for
the file specified by Filename.

Example
pro example_airsar_header_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the keywords
;
filename = indvc.dat
;
; Call the "doit"
;
envi_doit, airsar_header_doit, $
filename=filename, ns=ns, nl=nl, $
offset=offset, genfac=genfac, $
band=band
;
; Print the result
;
print, ns = , ns
print, nl = , nl
print, offset = , offset
print, genfac = , genfac
print, band = , band
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

AIRSAR_HEADER_DOIT

54

Chapter 2: ENVI Routines

AIRSAR_PED_HEIGHT_DOIT
Use this program to calculate pedestal height images from an AIRSAR compressed
stokes matrix.

Syntax
ENVI_DOIT, AIRSAR_PED_HEIGHT_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FNAME
Use this keyword to specify a string array of compressed stokes matrix file names for
C, L and/or P wavelengths respectively. If a file is not used, set the array element
to .

FNS
Use this keyword to specify the number of samples per line in the AIRSAR image.

FNL
Use this keyword to specify the number of lines in the AIRSAR image.

GENFAC
Use this keyword to specify an array of COMP SCALE FACTORS for each of the
files specified by FNAME.

AIRSAR_PED_HEIGHT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

55

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OFFSET
Use this keyword to specify a long array of header offsets for each of the files
specified by FNAME.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_airsar_ped_height_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the keywords
;
fname = [indvc.dat, $
indvl.dat, $
indvp.dat]
fns = 1024
fnl = 1224
out_type = 0
out_name = testimg
offset = [30720, 30720, 30720]

ENVI Reference Guide

AIRSAR_PED_HEIGHT_DOIT

56

Chapter 2: ENVI Routines


genfac = [18.1776, 6.51427, 1.63261]
dims = [-1, 0, fns-1, 0, fnl-1]
;
; Call the "doit"
;
envi_doit, airsar_ped_height_doit, $
fname=fname, offset=offset, $
fns=fns, fnl=fnl, dims=dims, $
out_name=out_name, genfac=genfac, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

AIRSAR_PED_HEIGHT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

57

AIRSAR_PHASE_IMAGE_DOIT
Use this program to calculate phase images from an AIRSAR compressed stokes
matrix.

Syntax
ENVI_DOIT, AIRSAR_PHASE_IMAGE_DOIT

Keywords
DEGREES
Set this optional keyword to output the phase images in degrees. Set this keyword to
zero to output the phase image in radians.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FNAME
Use this keyword to specify a string array of compressed stokes matrix file names for
C, L or P wavelengths. A phase image will be calculated for each element in
FNAME.

FNS
Use this keyword to specify the number of samples per line in the AIRSAR image.

FNL
Use this keyword to specify the number of lines in the AIRSAR image.

ENVI Reference Guide

AIRSAR_PHASE_IMAGE_DOIT

58

Chapter 2: ENVI Routines

GENFAC
Use this keyword to specify an array of COMP SCALE FACTORS for each of the
files specified by FNAME.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OFFSET
Use this keyword to specify a long array of header offsets for each of the files
specified by FNAME.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_airsar_phase_image_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the input and output file names
;
out_name = testimg
fname = [indvc.dat, $
indvl.dat, $

AIRSAR_PHASE_IMAGE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

59

indvp.dat]
;
; Set the keywords
;
fns = 1024
fnl = 1224
dims = [-1, 0, fns-1, 0, fnl-1]
out_type = 0
offset = [30720, 30720, 30720]
genfac = [18.1776, 6.51427, 1.63261]
out_bname = [Phase:indvc.dat, $
Phase:indvl.dat, $
Phase:indvp.dat]
;
; Call the "doit"
;
envi_doit, airsar_phase_image_doit, fname=fname, $
offset=offset, dims=dims, out_name=out_name, $
out_bname=out_bname, /degrees, genfac=genfac,$
in_memory=0, fns=fns, fnl=fnl, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

AIRSAR_PHASE_IMAGE_DOIT

60

Chapter 2: ENVI Routines

AIRSAR_POLSIG_DOIT
Use this program to calculate polarization signatures from an AIRSAR compressed
stokes matrix.

Syntax
ENVI_DOIT, AIRSAR_POLSIG_DOIT

Keywords
BANDS
Use this keyword to specify a three-element array of ones and zeros, indicating
whether the C, L and P wavelengths were used. A value of one indicates the
wavelength was used. BANDS must be three elements long, regardless of the size of
FNAME.

BFNAME
Use this keyword to specify a three-element string array, where each element
specifies C, L and P annotations for the header description. BFNAME must be three
elements long regardless of the size of FNAME.

FNAME
Use this keyword to specify a string array of compressed stokes matrix file names for
C, L and/or P wavelengths, respectively. If a file is not used, set the array element
to .

FNS
Use this keyword to specify the number of samples per line in the AIRSAR image.

FNL
Use this keyword to specify the number of lines in the AIRSAR image.

GENFAC
Use this keyword to specify an array of COMP SCALE FACTORS for each of the
files specified by FNAME.

AIRSAR_POLSIG_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

61

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OFFSET
Use this keyword to specify a long array of header offsets for each of the files
specified by FNAME.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

ROI_ID
Use this keyword to specify an array of ROI IDs returned from a call to
ENVI_GET_ROI_IDS. Each ID in the array will use the corresponding ROI to
calculate both a co-polarization and cross polarization image.

Example
forward_function envi_get_roi_ids
pro example_airsar_polsig_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the keywords

ENVI Reference Guide

AIRSAR_POLSIG_DOIT

62

Chapter 2: ENVI Routines


;
fname = [indvc.dat, $
indvl.dat, $
indvp.dat]
fns = 1024
fnl = 1224
out_type = 0
out_name = testimg
offset = [30720, 30720, 30720]
genfac = [18.1776, 6.51427, 1.63261]
out_bname = [CP:indvc.stk, XP:indvc.stk, $
CP:indvl.stk, XP:indvl.stk, $
CP:indvp.stk, XP:indvp.stk]
;
; Restore the presaved polsig ROI
;
envi_restore_rois, indv.roi
roi_id = envi_get_roi_ids(ns=fns, nl=fnl)
roi_id = [roi_id, roi_id, roi_id]
;
; Call the "doit"
;
envi_doit, airsar_polsig_doit, fname=fname, $
offset=offset, roi_id=roi_id, $
out_name=out_name, out_bname=out_bname, $
genfac=genfac, in_memory=0, fns=fns, $
fnl=fnl, bands=[1,1,1], bfname=fname, $
out_type=out_type, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

AIRSAR_POLSIG_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

63

AIRSAR_SCATTER_DOIT
Use this program to classify an AIRSAR image based on the scattering.

Syntax
ENVI_DOIT, AIRSAR_SCATTER_DOIT

Keywords
CLASS_NAMES
Use this keyword to specify names for each output class. CLASS_NAMES is an
array of strings with num_classes+1 elements. Remember to set the zero class to
Unclassified.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FNAME
Use this keyword to specify a string array of compressed stokes matrix file names for
C, L and P wavelengths, respectively. All wavelengths must be specified for this
function.

FNS
Use this keyword to specify the number of samples per line in the AIRSAR image.

FNL
Use this keyword to specify the number of lines in the AIRSAR image.

ENVI Reference Guide

AIRSAR_SCATTER_DOIT

64

Chapter 2: ENVI Routines

GENFAC
Use this keyword to specify an array of COMP SCALE FACTORS for each of the
files specified by FNAME.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

KX
Set this keyword to specify the X size, in pixels, of the averaging box.

KY
Set this keyword to specify the Y size, in pixels, of the averaging box.

LOOKUP
Use this keyword to specify an array of color tables values for the classification
image. Each output class can have a unique color triple [r, g, b], LOOKUP is a byte
array of size (3, num_classes+1). Remember that class zero must also have a color
triplet (commonly black [0,0,0]).

METHOD
Set this keyword equal to one of the following values to specify the type of
processing to perform.

0- Perform scattering computations only.

1- Classify the data based on the scattering mechanism.

For a Minimum rule decision, the class (or band) with the smallest value becomes the
selected class.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

AIRSAR_SCATTER_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

65

OFFSET
Use this keyword to specify a long array of header offsets for each of the files
specified by FNAME.

RULE_OUT_BNAME
Use this keyword to specify a string array that contains the output band names for the
rule image.

RULE_OUT_NAME
Use this keyword to specify an output filename for the rule image. If this item is
present, the rule image is automatically saved.

RULE_IN_MEMORY
Set this keyword to specify that output rule images should be stored in memory.

RULE_R_FID
Use this keyword to specify a named variable that will contain the file ID for the rule
image. This file ID can be used to access the data.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

XSTART
Use this keyword to specify the X offset of the input file. Set to 0 for no offset.

YSTART
Use this keyword to specify the Y offset of the input file. Set to 0 for no offset

Example
pro example_airsar_scatter_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors

ENVI Reference Guide

AIRSAR_SCATTER_DOIT

66

Chapter 2: ENVI Routines


; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the keywords
;
fname = [indvc.dat, $
indvl.dat, $
indvp.dat]
fns = 1024
fnl = 1224
out_type = 0
out_name = testimg
offset = [30720, 30720, 30720]
genfac = [18.1776, 6.51427, 1.63261]
dims = [-1, 0, fns-1, 0, fnl-1]
class_names = [$
Unclassified, $
No vegetation, $
Low vegetation, $
Dihedral Low vegetation, $
Forest, $
Dihedral Forest, $
Medium Vegetation, $
Dihedral Medium Vegetation, $
Urban]
lookup = [$
[ 0, 0, 0], [255, 0, 0], $
[ 0,255, 0], [ 0, 0,255], $
[255,255, 0], [255, 0, 255], $
[0, 255, 255], [128, 255, 0], $
[128, 0, 255]]
;
; Call the "doit"
;
envi_doit, airsar_scatter_doit, $
fname=fname, offset=offset, $
fns=fns, fnl=fnl, dims=dims, $
kx=3, ky=3, class_name=class_names, $
lookup=lookup, method=1, xstart=0, $
ystart=0, out_name=out_name, $
genfac=genfac, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

AIRSAR_SCATTER_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

67

AIRSAR_SYNTH_DOIT
Use this program to synthesize an AIRSAR image from a compressed stokes matrix.

Syntax
ENVI_DOIT, AIRSAR_SYNTH_DOIT

Keywords
COMBO
Use this keyword to specify a 5 x n array of ellipticity and orientation angles for each
image synthesized. The format for the array is:

(0,i) - transmit ellipticity for ith image.

(1,i) - transmit orientation for ith image.

(2,i) - receive ellipticity for ith image.

(3,i) - receive orientation for ith image.

(4,i) - stokes band number 0-C, 1-L, 2-P.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

DO_SQRT
Use this keyword to specify that the square root of the data be performed before
converting to byte. This keyword is used when the output data type is 1 (BYTE).

ENVI Reference Guide

AIRSAR_SYNTH_DOIT

68

Chapter 2: ENVI Routines

FNAME
Use this keyword to specify a three element string array of compressed stokes matrix
file names for C, L and/or P wavelengths, respectively. If a file is not used, set the
array element to .

FNS
Use this keyword to specify the number of samples per line in the AIRSAR image.

FNL
Use this keyword to specify the number of lines in the AIRSAR image.

GENFAC
Use this keyword to specify an array of COMP SCALE FACTORS for each of the
files specified by FNAME.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

MAX_VAL (optional)
Use this keyword to set an optional maximum value for output data.

OFFSET
Use this keyword to specify a long array of header offsets for each of the files
specified by FNAME.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OUT_DT
Use this keyword to specify the output data type, either 1 for byte or 4 for floating
point. All other output data types are invalid.

AIRSAR_SYNTH_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

69

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

SIGMA_ZERO
Set this keyword to specify that the output values be converted to sigma zero,
10*log10(data).

STDMULT
Set this keyword to specify the standard deviation multiplier for byte output data
types. Plus and minus the STDMULT determines the output minimum and
maximum.

TOTAL_POWER
Use this keyword to specify a three element array of ones and zeros indicating
whether the total power should be computed for the C, L and/or P wavelengths,
respectively. A value of one causes the synthesis of the total power image.

XFAC
Use this keyword to specify an X subsampling factor used to compute image data
statistics prior to the conversion to byte. This keyword is used when the output data
type is byte.

YFAC
Use this keyword to specify a Y subsampling factor used to compute image data
statistics prior to the conversion to byte. This keyword is used when the output data
type is byte.

Example
pro example_airsar_synth_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt

ENVI Reference Guide

AIRSAR_SYNTH_DOIT

70

Chapter 2: ENVI Routines


;
; Set the keywords
;
fname = [indvc.dat, $
indvl.dat, $
indvp.dat]
fns = 1024
fnl = 1224
out_type = 0
out_name = testimg
offset = [30720, 30720, 30720]
genfac = [18.1776, 6.51427, 1.63261]
dims = [-1, 0, fns-1, 0, fnl-1]
combo = [[0.,0.,0.,0.,0], $
[0.,0.,0.,0.,1], $
[0.,0.,0.,0.,2]]
total_power = lonarr(3) + 1
;
; Call the "doit"
;
envi_doit, airsar_synth_doit, $
fname=fname, offset=offset, $
fns=fns, fnl=fnl, dims=dims, $
combo=combo, out_name=out_name, $
total_power=total_power, out_dt=4, $
genfac=genfac, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

AIRSAR_SYNTH_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

71

ASPECT_DOIT
Use this program to make aspect corrections to Landsat MSS image data.

Syntax
ENVI_DOIT, ASPECT_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

ENVI Reference Guide

ASPECT_DOIT

72

Chapter 2: ENVI Routines

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_aspect_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; aspect correction on all samples
; and bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Perform the aspect correction
;
envi_doit, aspect_doit, $
fid=fid, pos=pos, dims=dims, $
out_name=out_name, r_fid=r_fid
;

ASPECT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

73

; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

ASPECT_DOIT

74

Chapter 2: ENVI Routines

AUTO_WID_MNG
Use this function to automatically perform event handling of ENVI compound
widgets, without the need to write an event-handler procedure. The function returns
an anonymous structure whose tag names are defined by the user values (uvalue) of
the widgets being managed. Each field contains the data item(s) listed under the
heading Widget Event for the compound widgets described in this section.
AUTO_WID_MNG automatically creates an OK and Cancel button on the widget
unless the optional keyword NO_BUTTONS is set. In all cases, if the OK button is
selected, the field result.accept (where result is the name of the structure
returned by AUTO_WID_MNG) is set to one. Otherwise, if the Cancel button is
selected then result.accept is set to zero.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = AUTO_WID_MNG (Base)

Arguments
Base
The widget ID of the base widget.

Keywords
COLUMN_BASE (optional)
Set this optional keyword to the widget ID of the base that will hold the Accept and
Cancel buttons. The default is to use the base widget specified by the Base argument.

NO_BUTTONS (optional)
Set this optional keyword to cause the widget to exit on the first event.

AUTO_WID_MNG

ENVI Reference Guide

Chapter 2: ENVI Routines

75

BAD_DATA_DOIT
Use this program to remove bad data lines from image data by averaging adjacent
lines.

Syntax
ENVI_DOIT. BAD_DATA_DOIT

Keywords
BAD_LINES
Use this keyword to specify an array of line numbers to replace. Note that line
numbers start with zero. BAD_LINES is a long integer array.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

ENVI Reference Guide

BAD_DATA_DOIT

76

Chapter 2: ENVI Routines

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

WIDTH
Use this keyword to specify how many lines above and below the bad line to use in
averaging. The total number of lines averaged is 2 * WIDTH. WIDTH is a long
integer greater than or equal to one.

Example
pro example_bad_data_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif

BAD_DATA_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

77

;
; Set the keywords. We will perform the
; aspect correction on all samples
; and bands in the file. We will
; correct lines 100, 120 and 167
; for bad data (these lines actually
; contain valid data but are being
; used for the example).
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
bad_lines = [100L, 120, 167]
;
; Perform the bad data correction.
; Use a width of one to correct
; for the bad lines.
;
envi_doit, bad_data_doit, $
fid=fid, pos=pos, dims=dims, $
out_name=out_name, width=1, $
bad_lines=bad_lines, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

BAD_DATA_DOIT

78

Chapter 2: ENVI Routines

CATCH
The CATCH procedure provides a generalized mechanism for the handling of
exceptions and errors. Calling CATCH establishes an error handler for the current
procedure that intercepts all errors that can be handled by IDL, excluding non-fatal
warnings such as math errors.
When an error occurs, each active procedure, beginning with the offending procedure
and proceeding up the call stack to the main program level, is examined for an error
handler. If an error handler is found, control resumes at the statement after the call to
CATCH. The index of the error is returned in the argument to CATCH. The !ERROR
(or !SYSERROR) and !ERR_STRING (or !SYSERR_STRING) system variables are
also set. If no error handlers are found, program execution stops, an error message is
issued, and control reverts to the interactive mode. A call to ON_IOERROR in the
procedure that causes an I/O error supersedes CATCH, and takes the branch to the
label defined by ON_IOERROR.
This mechanism is similar, but not identical to, the setjmp/longjmp facilities in C and
the catch/throw facilities in C++.

Syntax
CATCH, Variable

Arguments
Variable
A named variable in which the error index is returned. When an error handler is
established by a call to CATCH, Variable is set to zero. If an error occurs, Variable is
set to the error index and control is transferred to the statement after the call to
CATCH.

Keywords
CANCEL
Set this keyword to cancel the error handler for the current procedure. This
cancellation does not affect other error handlers that may be established in other
active procedures.

CATCH

ENVI Reference Guide

Chapter 2: ENVI Routines

79

CF_DOIT
Use this program to create an output file to disk or memory from bands in the
Available Bands List.

Syntax
ENVI_DOIT, CF_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify an array of file IDs, one for each band in the POS array.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_DT
Use this keyword to specify a named variable that will contain the IDL data type of
the file, using the following IDL convention:

1 byte (8-bits)

ENVI Reference Guide

CF_DOIT

80

Chapter 2: ENVI Routines

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, one for each file ID in the FID
array.

REMOVE
Set this keyword to delete input files that are completely contained in the new output
file from either disk or memory. WARNING: use this keyword with great caution;
files deleted in this manner cannot be restored.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_cf_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;

CF_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

81

; Initialize ENVI and send all errors


; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
t_fid = lonarr(nb) + fid
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Create the new output file. Do not
; remove the input file after the
; new file has been created.
;
envi_doit, cf_doit, $
fid=t_fid, pos=pos, dims=dims, $
remove=0, out_name=out_name, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

CF_DOIT

82

Chapter 2: ENVI Routines

CLASS_CONFUSION_DOIT
Use this program to compute the confusion matrix, commission, omission, accuracy
and kappa coefficient, between a classification image and its ground truth. Ground
truth can be specified as either a classification image using the keyword GTFID, or as
ROI using ROI_IDS keyword.

Syntax
ENVI_DOIT, CLASS_CONFUSION_DOIT

Keywords
ACCURACY (optional)
Use this keyword to specify a named variable that will contain the accuracy between
the classification image and the ground truth.

CALC_PERCENT
Set this keyword equal to one of the following values to specify either units for the
confusion matrix:

0 Output the confusion matrix in pixel counts

1 Output the confusion matrix in percent.

2 Output both types of confusion matrix.

CFID
Use this keyword to specify the file ID for the classification file. This is the value
returned from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a
long integer with a value greater than zero. An invalid file ID is specified as -1.

CLASS_PTR
Use this keyword to specify which classes in the classification image match the
ground truth ROIs or the ground truth classes specified by GT_PTR. The number of
elements of CLASS_PTR must equal the number of ROIs when using ROIs, or the
number of elements of CLASS_PTR must equal the number of elements of GT_PTR
when using a ground truth classification image.

CLASS_CONFUSION_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

83

COMMISSION (optional)
Use this keyword to specify a named variable that will contain the commission array
between the classification image and the ground truth.

CPOS
Use this keyword to specify the band position for the classification image band. For
classification images POS should be set to zero. POS is an array of long integers,
ranging from zero to the number of bands-1.

DIMS
Use this keyword to specify the spatial dimensions of the classification image on
which to perform the operation. DIMS is a five-element array of long integers with
the following definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

Note that the dimensions specified must be within the classification image, including
the first pixel offsets.

GT_NAMES
Use this keyword to specify names for each ground truth class. GT_NAMES is an
array of strings with the same number of elements as GT_PTR or ROI_IDS
depending on which type of ground truth is used.

GT_PTR
Use this keyword to specify which classes in the ground truth image match the
classification classes. This keyword is not needed if ROIs are used for ground truth.
The number of elements of GT_PTR must equal the number of elements of
CLASS_PTR.

GTDIMS
Use this keyword to specify the spatial dimensions of the ground truth image on
which to perform the operation. This keyword is not needed if ROIs are used for

ENVI Reference Guide

CLASS_CONFUSION_DOIT

84

Chapter 2: ENVI Routines

ground truth. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: A pointer to the region of interest. Set to -1 for non ROI items.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

Note that the dimensions specified must be within the classification image, including
the first pixel offsets.

GTFID
Use this keyword to specify the file ID for the ground truth file. This keyword is not
needed if ROIs are used for ground truth. This is the value returned from the keyword
R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer with a value
greater than zero. An invalid file ID is specified as -1.

GTPOS
Use this keyword to specify the band position for the ground truth image band. This
keyword is not needed if ROIs are used for ground truth. For classification images
POS should be set to zero. POS is an array of long integers, ranging from zero to the
number of bands-1.

KAPPA_COEFF (optional)
Use this keyword to specify a named variable that will contain the kappa coefficient
between the classification image and the ground truth.

MATRIX (optional)
Use this keyword to specify a named variable that will contain the confusion matrix
(in pixel counts) between the classification image and the ground truth.

OMISSION (optional)
Use this keyword to specify a named variable that will contain the omission array
between the classification image and the ground truth.

CLASS_CONFUSION_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

85

ROI_IDS
Use this keyword to specify the ROI ids for the ground truth. This keyword is not
needed if a ground truth image is used. Use the keyword GTFID in this case. The
number of ROI_IDS must be equal to the number of elements in the CLASS_PTR
array.

RPT_COMMISSION (optional)
Set this keyword to one to report the commission to the screen.

RULE_OUT_BNAME (optional)
Use this keyword to specify a string array that contains the output band names for the
rule image.

RULE_OUT_NAME (optional)
Use this keyword to specify an output filename for the rule image. If this item is
present, the rule image is automatically saved.

RULE_IN_MEMORY (optional)
Set this keyword to specify that output rule images should be stored in memory.

TO_SCREEN
Set this keyword to one to report the confusion matrix to the screen. Otherwise set
this value to zero.

Example
forward_function envi_get_roi_ids
pro example_class_confusion_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file

ENVI Reference Guide

CLASS_CONFUSION_DOIT

86

Chapter 2: ENVI Routines


;
envi_open_file, bhtm_class, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Restore the ground truth ROIs
;
envi_restore_rois, bhtm_nd.roi
roi_ids = envi_get_roi_ids(fid=fid)
;
; Set the necessary variables
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb, $
num_classes=num_classes
pos = [0]
dims = [-1, 0, ns-1, 0, nl-1]
out_name = testimg
class_ptr = lindgen(n_elements(roi_ids)) + 1
;
; Call the doit
;
envi_doit, class_confusion_doit, $
cfid=fid, cpos=pos, dims=dims, $
roi_ids=roi_ids, class_ptr=class_ptr, $
/rpt_commission, to_screen=0, $
calc_percent=0, commission=commission, $
omission=omission, matrix=matrix, $
kappa_coeff=kappa_coeff, accuracy=accuracy
;
print, commission
print, omission
print, matrix
print, kappa_coeff
print, accuracy
;
; Exit ENVI
;
envi_batch_exit
end

CLASS_CONFUSION_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

87

CLASS_CS_DOIT
Use this program to clump or sieve a classification image. The sieve operation uses a
blob technique to eliminate all blobs smaller than SIEVE_MIN. The clump process
uses the morphological operators dilate and erode.

Syntax
ENVI_DOIT, CLASS_CS_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

Note that the dimensions specified must be within the classification image, including
the first pixel offsets.

DKERN (Clump only)


Dilate kernel used for the classification Clump. This kernel is passed to the IDL
morphology routines.

EIGHT (Sieve only)


If this keyword is set, the sieve function searches the eight-neighbor region around a
pixel, rather than the four-neighbor region, for continuous blobs. The four-neighbor
region around a pixel consists of two adjacent horizontal and two adjacent vertical
neighbors. The eight-neighbor region around a pixel consists of all the immediately
adjacent pixels.

ENVI Reference Guide

CLASS_CS_DOIT

88

Chapter 2: ENVI Routines

EKERN (Clump only)


Erode kernel used for the classification Clump. This kernel is passed to the IDL
morphology routines.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

METHOD
Set this keyword equal to one of the following values to specify either sieve or
clump:

0 Clump

1 Sieve

ORDER
Use this keyword to specify the order in which clump or sieve is applied to the
classification image. If not specified, the classes are processed from first to last.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

CLASS_CS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

89

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

SIEVE_MIN (Sieve only)


Use this keyword to specify the minimum size of a blob to keep. All blobs smaller
then SIEVE_MIN will be removed. Use the EIGHT keyword to specify the pixel
neighbors from which to build blobs.

Example
pro example_class_cs_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtm_sam.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the necessary variables
;
envi_file_query, fid, ns=ns, nl=nl, $
num_classes=num_classes
pos = [0]
dims = [-1, 0, ns-1, 0, nl-1]
out_name = testimg
dkern = bytarr(3,3) + 1b
ekern = dkern
order = bindgen(num_classes)
;
; Call the doit
;
envi_doit, class_cs_doit, fid=fid, $
pos=pos, dims=dims, order=order, $

ENVI Reference Guide

CLASS_CS_DOIT

90

Chapter 2: ENVI Routines


dkern=dkern, ekern=ekern, method=0, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

CLASS_CS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

91

CLASS_DOIT
Use this program to perform supervised classification using the Parallelepiped,
Minimum Distance, Maximum Likelihood, Spectral Angle Mapper, Mahalanobis, or
Binary Encoding methods, or unsupervised classification using ISODATA or
K-Means. All classification methods use both the common setup keywords and
classification-method specific keywords. The METHOD keyword is used to select
the supervised or unsupervised classification technique.

Syntax
ENVI_DOIT, CLASS_DOIT

Keywords
CLASS_NAMES
Use this keyword to specify names for each output class for the supervised
classification methods (the unsupervised methods generate their own
CLASS_NAMES based on the color of the class). CLASS_NAMES is an array of
strings with num_classes+1 elements. The first element of CLASS_NAMES is the
unclassified class and is typically called Unclassified. The order of the other
classes is determined by the order of the classification data in the keyword MEAN.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

ENVI Reference Guide

CLASS_DOIT

92

Chapter 2: ENVI Routines

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

LOOKUP
Use this keyword to specify a long array of class RGB values for the supervised
methods only (the unsupervised methods generate their own LOOKUP based on the
number of output classes). The LOOKUP array contains an RGB triplet for the
Unclassified class plus one RGB triple for each output class. The Unclassified class,
class zero, typically uses the RGB triplet [0,0,0] for black. The dimensions of the
array are [3,num_classes+1] and the RGB triplet is ordered [R,G,B]. Class zero,
LOOKUP[*,0], is the Unclassified class and the order of the other classes is
determined by the order of the classification data in keyword MEAN.

M_FID (optional)
Use this keyword to specify the file ID for the mask file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

M_POS (optional)
Use this keyword to specify the band position of the mask band. M_POS is a single
long value greater than or equal to zero.

METHOD
Set this keyword equal to one of the following values to specify the classification
method:

CLASS_DOIT

0 Parallelepiped (Supervised)

1 Minimum Distance (Supervised)

2 Maximum Likelihood (Supervised)

3 Spectral Angle Mapper (Supervised)

4 Isodata (Unsupervised)
ENVI Reference Guide

Chapter 2: ENVI Routines

5 Mahalanobis (Supervised)

6 Binary Encoding (Supervised)

7 K-Means (Unsupervised)

93

OUT_BNAME (optional)
Use this optional keyword to specify an output band name. OUT_BNAME is a single
string value representing the classification image band name.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Keywords for Supervised Classification


The following keywords can be used with any of the supervised classification
methods (parallelepiped, minimum distance, maximum likelihood, Mahalanobis
distance spectral angle mapper, and binary encoding):

MEAN
Use this keyword to specify the mean spectral values for each class when performing
supervised classification. MEAN is a floating-point or double-precision array of
[nb,num_classes] values. The spectral mean of each class (for supervised methods) is
commonly computed from the spectral mean of the ROI representing the training
region of the class. The actual number of output classes, NUM_CLASSES, is
computed from the number of spectral means plus one for the Unclassified class.

ENVI Reference Guide

CLASS_DOIT

94

Chapter 2: ENVI Routines

Note
For the unsupervised methods of ISODATA and K-Means, the initial starting
classes are calculated automatically from the mean on the input data and do not
require the MEAN keyword.

RULE_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed rule image. This file ID can be used to access the processed data.

RULE_OUT_BNAME (optional)
Use this keyword to specify a string array that contains the output band names for the
rule image.

RULE_OUT_NAME (optional)
Use this keyword to specify an output filename for the rule image. If this item is
present, the rule image is automatically saved.

RULE_IN_MEMORY (optional)
Set this keyword to specify that output rule images should be stored in memory.

Keywords for Parallelepiped Classification


STDV
Use this keyword to specify a floating-point or double-precision array of the form
(num_bands, num_classes) containing the standard deviation for each of the spectral
classes.

STD_MULT (optional)
Use this optional keyword to specify a floating-point or double-precision
multiplication factor or array of factors (one for each class) specifying the width
around the standard deviation within which spectrum may fall and still be classified
into that class. If an array is specified, each class is tested with its corresponding
width. The default is 1.0.

CLASS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

95

Keywords for Minimum Distance Classification


DATA_SCALE (optional)
Use this optional keyword to specify a floating-point value representing the data
scale factor. The scale factor is a division factor used to convert integer scaled
reflectance or radiance data into floating-point values. For example, for reflectance
data scaled into the range of zero to 10,000, set the scale factor to 10,000. For
uncalibrated integer data, set the scale factor to the maximum value the instrument
can measure ((2n) - 1, where n is the bit depth of the instrument). For example, for 8bit instruments (such as Landsat 4) set the scale factor to 255, for 10-bit instruments
(such as NOAA 12 AVHRR) set the scale factor to 1023, for 11-bit instruments (such
as IKONOS) set the scale factor to 2047.

STDV
Use this keyword to specify a floating-point or double-precision array of the form
(num_bands, num_classes) containing the standard deviation for each of the spectral
classes. This value must be specified if STD_MULT is specified.

STD_MULT (optional)
Use this optional keyword to specify a floating-point or double-precision
multiplication factor or array of factors (one for each class) specifying the width
around the standard deviation within which spectrum may fall and still be classified
into that class. If an array is specified, each class is tested with its corresponding
width. The default is 1.0. If SDT_MULT is specified, the keyword STDV must be
set.

THRESH (optional)
Use this optional keyword to specify a floating-point or double-precision maximum
distance error or array of errors (one for each class) by which a spectral value can
differ from the mean value. If an array is specified, each class is tested against its
corresponding error. When a single value is specified, THRESH is applied class by
class, not as the total error.

ENVI Reference Guide

CLASS_DOIT

96

Chapter 2: ENVI Routines

Keywords for Maximum Likelihood Classification


COV
Use this keyword to specify a floating-point or double-precision array of the form
(num_bands, num_bands, num_classes) containing the covariance of the
classification spectrum used.

STDV
Use this keyword to specify a floating-point or double-precision array of the form
(num_bands, num_classes) containing the standard deviation for each of the spectral
classes.

THRESH (optional)
Use this optional keyword to specify a floating-point or double-precision minimum
probability or array of probabilities (one for each class) that a class must have in
order to be classified. If an array is specified, each class is tested against its
corresponding probability.

Keywords for Spectral Angle Mapper Classification


THRESH (optional)
Use this optional keyword to specify a floating-point or double-precision maximum
angle or array of maximum angles (one for each class) specifying the maximum
angle to classify (in radians). If an array is specified, each class is tested against its
corresponding maximum spectral angle. THRESH should have a value between zero
and /2. The default value is /2.

Keywords for Mahalanobis


COV
Use this keyword to specify a floating-point or double-precision array of the form
(num_bands, num_bands, num_classes) containing the covariance of the
classification spectrum used.

CLASS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

97

NPTS
Use the NPTS keyword to specify the number of points in each ROI. This keyword
contains a longword integer array data type with one element per ROI. Use the
ENVI_GET_ROI_INFORMATION routine to get the number of points in each ROI.

THRESH (optional)
Use this optional keyword to specify a floating-point or double-precision maximum
distance error or array of errors (one for each class) by which a spectral value can
differ from the mean value. If an array is specified, each class is tested against its
corresponding error. When a single value is specified, THRESH is applied class by
class, not as the total error.

Keywords for Binary Encoding


THRESH (optional)
Use this optional keyword to specify floating-point or double-precision minimum
match percent or array of minimum match percents (one for each class). The value of
THRESH is between 0.0 and 1.0 ranging from 0% to 100%. If an array is specified,
each class is tested against its corresponding minimum match percent. For example, a
value of 1.0 means that all bands must match and a value of .4 means that at least
40% of the bands must match the binary encoding.

Keywords for Unsupervised Classification


The following keywords can be used with any of the unsupervised classification
methods (K-Means and ISODATA):

STD_MULT (optional)
Use this keyword to specify a floating-point multiplication factor specifying the
width around the standard deviation within which a spectrum may fall and still be
classified into that class. The default is 1.0.

THRESH (optional)
Use this keyword to specify the maximum distance error by which a spectral value
can differ from a mean value. The THRESH value is applied band by band, not as the
total error.

ENVI Reference Guide

CLASS_DOIT

98

Chapter 2: ENVI Routines

ITERATIONS
Use this keyword to specify the maximum iteration count.

Keywords for K-Means


CHANGE_THRESH
Set this keyword to a floating-point number between zero and one to specify the
percentage of pixels which can change classes during each iteration. If the percentage
of pixels that will change in a given iteration is greater than the CHANGE_THRESH
value, another iteration is performed, provided that the maximum number of
iterations is not exceeded. If the percentage is less then the threshold, the
classification is complete. A value of 1.0 means 100%.

NUM_CLASSES
Use this keyword to specify the desired number of output classes.

Keywords for ISODATA


CHANGE_THRESH
Set this keyword to a floating-point number between zero and one to specify the
percentage of pixels which can change classes during each iteration. If the percentage
of pixels that will change in a given iteration is greater than the CHANGE_THRESH
value, another iteration is performed, provided that the maximum number of
iterations is not exceeded. If the percentage is less then the threshold, the
classification is complete. A value of 1.0 means 100%.

ISO_MERGE_DIST
Set this keyword to a floating-point number greater than zero to specify the class
merge distance (in DN). If the distance between class means is less than
ISO_MERGE_DIST, the classes will be merged. The maximum number of pairs
merged in any loop is determined by ISO_MERGE_PAIRS

ISO_MERGE_PAIRS
Set this keyword to a long value to specify the maximum number of classes that can
be merged in a single iteration.

CLASS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

99

ISO_MIN_PIXELS
Set this keyword to a long value to specify the minimum number of pixels needed to
form a class. If there are few pixels in the class, that class will be deleted.

ISO_SPLIT_STD
Set this keyword to a floating-point number greater than zero to specify the minimum
class standard deviation value (in DN). If a class standard deviation is greater than
ISO_SPLIT_STD, the class is split into two classes.

ISO_SPLIT_SMULT (optional)
Set this keyword to a floating-point number greater than zero to specify the standard
deviation multiplier used to calculate the mean of split classes. The new means are
calculated as follows
class_1_mean = class_mean + ISO_SPLIT_STD * current_stdv
class_2_mean = class_mean - ISO_SPLIT_STD * current_stdv

The default value is 1.

MIN_CLASSES
Use this keyword to specify the desired minimum number of output classes.

NUM_CLASSES
Use this keyword to specify the desired maximum number of output classes.

Example
This example performs a supervised Maximum Likelihood classification using ROIs
previously saved to an ROI file. The Maximum Likelihood method requires setting
the keywords MEAN, STDV, and COV. The routine ENVI_STATS_DOIT is used to
calculate the ROI mean, standard deviation, and covariance. The class names and
colors come from the ROI names and colors respectively.
This example uses the following files found on the ENVI Tutorial and Data CD
No. 1:

envidata/bh_tmsub/bhtm_mnf.img

envidata/bh_tmsub/bhtm_mnf.hdr

envidata/bh_tmsub/bhtm_nd.roi
forward_function envi_get_roi_ids, envi_get_roi_dims_ptr

ENVI Reference Guide

CLASS_DOIT

100

Chapter 2: ENVI Routines

pro example_class_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtm_mnf.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Get the samples, lines and # bands
; for the input file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
;
; Set the dims and pos to classify all
; data (spatially and spectrally) in the file.
;
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Restore the pre saved regions of interest.
; Set the class names equal to the roi
; names and use the roi colors as the
; class colors.
;
envi_restore_rois, bhtm_nd.roi
roi_ids = envi_get_roi_ids(fid=fid, $
roi_colors=roi_colors, roi_names=class_names)
class_names = [Unclassified, class_names]
num_classes = n_elements(roi_ids)
lookup = bytarr(3, num_classes + 1)
; Set the unclassified class to black and use roi colors
lookup = bytarr(3,num_classes+1)
lookup[0,1] = roi_colors
;
; Calculate the statistics from each region of interest.
; Each ROI specifies the training area for each class.

CLASS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

101

; The calculated MEAN, STDV and COV will be passed


; to the classifcation routine.
;
mean = fltarr(n_elements(pos), num_classes)
stdv = fltarr(n_elements(pos), num_classes)
cov = fltarr(n_elements(pos),n_elements(pos),num_classes)
for j=0, num_classes-1 do begin
; get the statistics for each selected class
roi_dims=[envi_get_roi_dims_ptr(roi_ids[j]),0,0,0,0]
envi_doit, envi_stats_doit, fid=fid, pos=pos, $
dims=roi_dims, comp_flag=4, mean=c_mean, $
stdv=c_stdv, cov=c_cov
mean[0,j] = c_mean
stdv[0,j] = c_stdv
cov[0,0,j] = c_cov
endfor
;
; Calculate the Maximum Likelihood supervised
; classification.
;
envi_doit, class_doit, fid=fid, pos=pos, dims=dims, $
out_bname=Max Like, out_name=out_name, method=2, $
mean=mean, stdv=stdv, std_mult=st_mult, r_fid=r_fid, $
lookup=lookup, cov=cov, class_names=class_names, $
num_classes=num_classes, in_memory=0
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

CLASS_DOIT

102

Chapter 2: ENVI Routines

CLASS_MAJORITY_DOIT
Use this program to perform majority or minority analysis on a classification image.
The keyword CLASS_PTR determines which classes to modify during processing.

Syntax
ENVI_DOIT, CLASS_MAJORITY_DOIT

Keywords
CLASS_PTR
Use this keyword to specify a long-integer array of class numbers on which to
perform analysis.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]:Unused for this function, set to -1.

DIMS[1]:The starting X pixel. (The first pixel is number zero.)

DIMS[2]:The ending X pixel.

DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

DIMS[4]:The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

CLASS_MAJORITY_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

103

KERNEL_SIZE
Use this keyword to specify a kernel size for the majority and minority analysis.
KERNEL_SIZE is a two element array specifying the X and Y kernel size,
respectively.

METHOD
Set this keyword equal to one of the following values to specify the analysis method:

0 Majority

1 Minority

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_class_majority_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;

ENVI Reference Guide

CLASS_MAJORITY_DOIT

104

Chapter 2: ENVI Routines


; Open the input file
;
envi_open_file, bhtm_sam.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the necessary variables
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb, $
num_classes=num_classes
pos = [0]
dims = [-1l, 0, ns-1, 0, nl-1]
out_name = testimg
method = 0
kernel_size = [5,5]
class_ptr = lonarr(num_classes) + 1
;
; Call the doit
;
envi_doit, class_majority_doit, fid=fid, $
pos=pos, dims=dims, method=method, $
kernel_size=kernel_size, out_name=out_name, $
class_ptr=class_ptr
;
; Exit ENVI
;
envi_batch_exit
end

See Also
CLASS_CS_DOIT
CLASS_DOIT

CLASS_MAJORITY_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

105

CLASS_RULE_DOIT
Use this program to classify rule images.

Syntax
ENVI_DOIT, CLASS_RULE_DOIT

Keywords
CLASS_NAMES
Use this keyword to specify names for each output class. CLASS_NAMES is an
array of strings with num_classes+1 elements. Remember to set the zero class to
Unclassified.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

Note that the dimensions specified must be within the classification image, including
the first pixel offsets.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

ENVI Reference Guide

CLASS_RULE_DOIT

106

Chapter 2: ENVI Routines

LOOKUP
Use this keyword to specify an array of color table values for the classification image.
Each output class can have a unique color triple [r, g, b], LOOKUP is a byte array of
size (3, num_classes+1). Remember that class zero must also have a color triplet
(commonly black [0,0,0]).

METHOD
Set this keyword equal to one of the following values, to specify either a minimum or
maximum rule decision:

0 Minimum

1 Maximum

For a Minimum rule decision, the class (or band) with the smallest value becomes the
selected class.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

THRESH (optional)
Use this keyword to specify an optional minimum (METHOD=0) or maximum
(METHOD = 1) threshold for classifying the rule image. If no threshold is specified,
the entire image will be classified.

Example
pro example_class_rule_doit
;
; First restore all the base save files.

CLASS_RULE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

107

;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtm_rul.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the necessary variables
;
envi_file_query, fid, ns=ns, nl=nl, $
nb=nb, bnames=bnames
pos = lindgen(nb)
dims = [-1, 0, ns-1, 0, nl-1]
out_name = testimg
class_names = [Unclassified, bnames]
;
; Build the lookup table
;
lookup = bytarr(3,nb+1)
for i=1,nb do begin
envi_get_rgb_triplets, i+1, r, g, b
lookup[0,i] = [r,g,b]
endfor
;
; Call the doit
;
envi_doit, class_rule_doit, $
fid=fid, pos=pos, dims=dims, $
lookup=lookup, method=0, $
class_names=class_names, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

CLASS_RULE_DOIT

108

Chapter 2: ENVI Routines

CLASS_STATS_DOIT
Use this program to calculate statistics for images based on classification mask.

Syntax
ENVI_DOIT, CLASS_STATS_DOIT

Keywords
CLASS_DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

Note that the dimensions specified must be within the classification image, including
the first pixel offsets.

CLASS_FID
Use this keyword to specify the file ID of the classification image.

CLASS_PTR
Use this keyword to specify a long-integer array of class numbers on which to
perform statistics.

COMP_FLAG
Set this keyword equal to a bit value indicating the computations to perform.

bit 0 not used.

bit 1 enables the calculation of histograms.

bit 2 enables the calculation of covariance.

CLASS_STATS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

109

bits 3 to 15 not used.

COV (optional)
Use this keyword to specify a named variable that will contain the returned
covariance matrix. You must set bit 2 in COMP_FLAG (i.e. COMP_FLAG=4) to
generate the covariance matrix.

DMAX (optional)
Use this keyword to specify a named variable that will contain the array of data
maximums, one for each band position.

DMIN (optional)
Use this keyword to specify a named variable that will contain the array of data
minimums, one for each band position.

EVAL (optional)
Use this keyword to specify a named variable that will contain the eigenvalues. You
must set bit 2 in COMP_FLAG (i.e. COMP_FLAG = 4) to generate the covariance
matrix.

EVEC (optional)
Use this keyword to specify a named variable that will contain the eigenvector. You
must set bit 2 in COMP_FLAG (i.e. COMP_FLAG = 4) to generate the covariance
matrix.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

HIST (optional)
Use this keyword to specify a named variable that will contain the histogram array.
You must set bit 1 in COMP_FLAG (i.e. COMP_FLAG = 2) to generate the
histogram output.

MEAN (optional)
Use this keyword to specify a named variable that will contain the array of data
means, one for each band position.
ENVI Reference Guide

CLASS_STATS_DOIT

110

Chapter 2: ENVI Routines

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

REP_NAME (optional)
Use this keyword to specify a string array containing the file name for the output
report file.

REPORT_FLAG (optional)
Set this keyword equal to a bit value indicating the type of output reports desired.
Logically AND the bit values together to get the desired reports.

bit 0 basic statistics. value=1.

bit 1 generate histogram report (the default), value=2.

bit 2 generate covariance report, value=4.

bits 3 to 15 not used.

If report flag is zero, no output report is generated.

STA_NAME (optional)
Use this keyword to specify a string array containing the file name for the output
statistics file.

STDV (optional)
Use this keyword to specify a named variable that will contain the array of data
standard deviations, one for each band position.

TO_SCREEN (optional)
Set this keyword to print the report on the screen. This keyword only controls the
display of the secondary statistics report window. The main statistics report window
will appear regardless of this keyword.

Example
pro example_class_stats_doit
;
; First restore all the base save files.

CLASS_STATS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

111

;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the data and class files
;
envi_open_file, bhtmref.img, r_fid=fid
envi_open_file, bhtm_sam.img, r_fid=cfid
if (fid eq -1 or cfid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the necessary variables
;
envi_file_query, cfid, num_classes=num_classes
class_ptr = indgen(num_classes)
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = class_stats.txt
;
; Call the doit
;
envi_doit, class_stats_doit, fid=fid, pos=pos, $
dims=dims, comp_flag=0, report_flag=1, $
rep_name=out_name, class_fid=cfid, $
class_ptr=class_ptr
;
; Exit ENVI
;
envi_batch_exit
end

See Also
ENVI_GET_STATISTICS
ENVI_STATS_DOIT
ENVI_WRITE_STATISTICS

ENVI Reference Guide

CLASS_STATS_DOIT

112

Chapter 2: ENVI Routines

COM_CLASS_DOIT
Use this program to combine classes in ENVI classified images.

Syntax
ENVI_DOIT, COM_CLASS_DOIT

Keywords
COMB_LUT
Use this keyword to specify a long-integer array indicating the output class for each
input class. Each element in the array indicates the output class for the current input
class. COMB_LUT has num_classes elements.
For example, if you wanted to map class 0 to 0, class 1 to 0, class 2 to 3, and class 3
to 2, you would use the following keyword specification:
comb_lut = [0, 0, 3, 2]

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

COM_CLASS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

113

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

REMOVE_EMPTY
Set this keyword to remove empty classes after combining. If empty classes are not
removed, one or more classes with zero elements may exist in the output image. The
default is to leave the empty classes.

Example
pro example_com_class_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtm_sam.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the necessary variables
;
envi_file_query, fid, ns=ns, nl=nl, $
num_classes=num_classes
pos = [0]

ENVI Reference Guide

COM_CLASS_DOIT

114

Chapter 2: ENVI Routines


dims = [-1, 0, ns-1, 0, nl-1]
out_name = testimg
comb_lut = lindgen(num_classes)
comb_lut[1] = 0
comb_lut[4] = 2
comb_lut[5] = 2
;
; Call the doit
;
envi_doit, com_class_doit, $
fid=fid, pos=pos, dims=dims, $
comb_lut=comb_lut, /remove_empty, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

COM_CLASS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

115

CONTINUUM_REMOVE_DOIT
Use this program to perform continuum removal on the data.

Syntax
ENVI_DOIT, CONTINUUM_REMOVE_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

M_FID
Use this keyword to specify the file ID for the mask file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

ENVI Reference Guide

CONTINUUM_REMOVE_DOIT

116

Chapter 2: ENVI Routines

M_POS
Use this keyword to specify the band position of the mask band. M_POS is a single
long value greater than or equal to zero.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify a one-dimension array of band positions indicating the
band numbers to perform the operations on. POS is a long array ranging from 0 to the
number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_continuum_remove_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the

CONTINUUM_REMOVE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

117

; continuum removal on all samples


; and bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Perform the continuum removal
;
envi_doit, continuum_remove_doit, $
fid=fid, pos=pos, dims=dims, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

CONTINUUM_REMOVE_DOIT

118

Chapter 2: ENVI Routines

CONV_DOIT
Use this program to perform convolution filtering, including high pass, low pass,
laplacian, gaussian, median, directional, sobel, roberts, and user-defined. For
methods 1 and 2 the output data type is automatically set to INTEGER (IDL type = 2)
and for the remaining methods the output data type is converted as follows:

Input BYTE(1) converts to INTEGER(2)

Input UNSIGNED INTEGER (12) converts to INTEGER(2)

Input UNSIGNED LONG (13) converts to LONG (3)

Syntax
ENVI_DOIT, CONV_DOIT

Keywords
ADD_BACK
Set this keyword equal to a floating-point or double-precision number between 0.0
and 1.0, specifying the filter add-back percentage. A value of 1.0 is equal to 100%.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

CONV_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

119

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

KERNEL
Use this keyword to specify a convolution kernel for methods 4 through 8.

KX
Use this keyword to specify the X kernel size. For methods 0 through 3, KX must be
equal to KY. For methods 0 and 1, KX must be set equal to three.

KY
Use this keyword to specify the Y kernel size. For methods 0 through 3, KY must be
equal to KX. For methods 0 and 1, KY must be set equal to three.

METHOD
Use this keyword to specify the type of filter to apply. Choose one of the following:

0 Sobel

1 Roberts

2 Median

3 Low pass

4 High pass

5 Laplacian

6 Directional

7 Gaussian

8 User defined

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

ENVI Reference Guide

CONV_DOIT

120

Chapter 2: ENVI Routines

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_conv_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the data and class files
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the necessary variables
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb, $
bname=bname
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
method = 2
;
; Call the doit
;
envi_doit,conv_doit, fid=fid, pos=pos, $
dims=dims, out_name=out_name, $
out_bname=bname(pos), method=method, $
kx=5, ky=5, add_back=.2, in_memory=0, $

CONV_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

121

r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

CONV_DOIT

122

Chapter 2: ENVI Routines

CONVERT_DOIT
Use this program to convert interleave type between BSQ, BIL, and BIP.

Syntax
ENVI_DOIT, CONVERT_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

O_INTERLEAVE
Set this keyword equal to zero to specify BSQ interleave output, one to specify BIL
output, or two to specify BIP output.

OUT_NAME
Use this keyword to specify an output file name for the resulting data.

CONVERT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

123

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_convert_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; continuum removal on all samples
; and bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Perform the file conversion. Convert
; the input BSQ image to BIL storage
; order.
;
envi_doit, convert_doit, $
fid=fid, pos=pos, dims=dims, $

ENVI Reference Guide

CONVERT_DOIT

124

Chapter 2: ENVI Routines


o_interleave=1, out_name=out_name, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

CONVERT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

125

CONVERT_INPLACE_DOIT
Use this program to convert, in place, an ENVI file from one storage interleave to
another. The program allows conversion between BSQ, BIL, and BIP storage
interleaves, without creating temporary files.

Syntax
ENVI_DOIT, CONVERT_INPLACE_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

O_INTERLEAVE
Use this keyword to specify the output interleave. Set to zero to convert to Band
Sequential (BSQ) format, one to convert to Band Interleave by Line (BIL) format, or
two to convert to Band Interleave by Pixel (BIP) format.

POS
Use this keyword to specify a one element array of the band positions to perform the
operations on. POS is a single element long array, ranging from 0 to the number of
bands-1.
ENVI Reference Guide

CONVERT_INPLACE_DOIT

126

Chapter 2: ENVI Routines

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_convert_inplace_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the data and class files
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the necessary variables
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb, $
interleave=interleave
o_interleave = ([1,2,0])[interleave]
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
;
; Call the doit
envi_doit,convert_inplace_doit, fid=fid, $
pos=pos, dims=dims, $
o_interleave=o_interleave, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

CONVERT_INPLACE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

127

See Also
CONVERT_DOIT

ENVI Reference Guide

CONVERT_INPLACE_DOIT

128

Chapter 2: ENVI Routines

CROSS_TRACK_CORRECTION_DOIT
Use Cross-Track Illumination Correction to remove variation in the cross-track
illumination of an image. Cross track illumination variations may be due to
vignetting effects, instrument scanning, or other non-uniform illumination effects.
Along-track mean values are calculated and are used to show the mean variation in
the cross-track direction. A polynomial function, with a defined order, is fit to the
means and used to remove the variation. In addition,
CROSS_TRACK_CORRECTION _DOIT is used to perform antenna pattern
correction on radar images. Radar images typically have a variation in gain across the
range direction (cross-track), due to the instruments antenna gain pattern. The CrossTrack provides enough control to perform either the illumination correction or the
antenna pattern correction.

Syntax
ENVI_DOIT, CROSS_TRACK_CORRECTION _DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending0 Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

CROSS_TRACK_CORRECTION_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

129

IN_MEMORY (optional)
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk and OUT_NAME must be specified. If
IN_MEMORY is set, OUT_NAME is not used.

M_FID (optional)
Use this optional keyword to specify the file ID for the mask file. This is the value
returned from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a
long integer with a value greater than zero. An invalid file ID is specified as -1. The
mask is used for computing the correction and optionally applied to the output image.
See the keyword MASK_OUTPUT.

M_POS (optional)
Use this optional keyword to specify the band position of the mask band. M_POS is a
single long value greater than or equal to zero. The mask is used for computing the
correction and optionally applied to the output image (see the keyword
MASK_OUTPUT).

MASK_OUTPUT (optional)
Set this optional keyword to apply the mask to the output image. By default, the
optional mask information (keyword M_FID and M_POS) is applied only when
calculating the polynomial correction. If M_FID and M_POS are not set, this
keyword has no effect.

METHOD
Set this keyword to one of the following values to specify the correction method.

0 Additive

1 Multiplicative

ORDER (optional)
Use this optional keyword to specify the order of the polynomial for the cross-track
illumination or antenna-pattern correction. A polynomial function with the defined
order is fit to the means of the data specified by RANGE_DIR and used to remove
the variations. The default is 1, a first degree polynomial.

OUT_BNAME (optional)
Use this optional keyword to specify a string array of output band names, if desired.
ENVI Reference Guide

CROSS_TRACK_CORRECTION_DOIT

130

Chapter 2: ENVI Routines

OUT_NAME
Use this keyword to specify an output file name for the resulting data. OUT_NAME
is a string variable specifying the filename and path of the output file.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this optional keyword to specify a named variable that will contain the file ID for
the processed data. This file ID can be used to access the processed data. An invalid
file ID is specified as -1.

RANGE_DIR
Set this keyword to one of the following values, to specify the cross-track or range
direction.

0 Samples. The cross-track or range direction is across the samples of a


single line

1 Lines. The cross-track or range direction is across the lines of a single


sample.

Example
This example is used to compute the cross-track correction for the file
bhtmref.img. The correction is applied to all pixels and all bands, without any
masking. The cross-track or range direction is set to samples using the RANGE_DIR
keyword. The ORDER keyword is set to a second order polynomial and the
METHOD keyword is used to perform a multiplicative correction. The output is
stored to disk.

CROSS_TRACK_CORRECTION_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

131

This example uses the following files found in the data directory of the ENVI
installation:

bhtmref.img

bhtmref.hdr

Note
This correction is not scientifically validit is applied to this image only to
demonstrate the use of the processing routine.
pro example_cross_track_correction_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; cross track correction on all samples
; and bands in the file. The correction will
; be in the samples direction, multiplicative,
; and with a 2nd order polynomial.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1L, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
range_dir = 0
method = 1
order = 2
;
; Perform the cross track correction
;
envi_doit, cross_track_correction_doit, $
fid=fid, pos=pos, dims=dims, $
range_dir=range_dir, out_name=out_name, $

ENVI Reference Guide

CROSS_TRACK_CORRECTION_DOIT

132

Chapter 2: ENVI Routines


method=method, order=order, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

See Also
EMITTANCE_CALC_DOIT
ENVI_AVHRR_CALIBRATE_DOIT
ENVI_CAL_DOIT
TIMS_CAL_DOIT
TMCAL_DOIT

CROSS_TRACK_CORRECTION_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

133

DARK_SUB_DOIT
Use this program to do dark region subtraction for atmospheric scattering correction.

Syntax
ENVI_DOIT, DARK_SUB_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

ENVI Reference Guide

DARK_SUB_DOIT

134

Chapter 2: ENVI Routines

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

VALUES
Use this keyword to specify an array of values to subtract from each band of the data.
The size of the array is equal to the number of elements in POS.

Example
pro example_dark_sub_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; continuum removal on all samples
; and bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
values = [10,5,9,7,2,13]
;

DARK_SUB_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

135

; Perform the dark current subtraction.


;
envi_doit, dark_sub_doit, $
fid=fid, pos=pos, dims=dims, $
values=values, out_name=out_name, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

DARK_SUB_DOIT

136

Chapter 2: ENVI Routines

DECOR_DOIT
Use this program to remove high correlation between three bands to make a saturated
color image.

Syntax
ENVI_DOIT, DECOR_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify an array of three file IDs for the RGB bands in the
decorrelation stretch.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

DECOR_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

137

POS
Use this keyword to specify an array of three band positions corresponding to the file
IDs in the FID array.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_decor_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; decorrelation stretch on the first
; three bands in the file and all
; spatial pixels.
;
envi_file_query, fid, ns=ns, nl=nl
t_fid = [fid,fid,fid]
dims = [-1, 0, ns-1, 0, nl-1]
pos = [0,1,2]
out_name = testimg
;
; Perform the decorrelation stretch
;
envi_doit, decor_doit, $
fid=t_fid, pos=pos, dims=dims, $
out_name=out_name, r_fid=r_fid

ENVI Reference Guide

DECOR_DOIT

138

Chapter 2: ENVI Routines


;
; Exit ENVI
;
envi_batch_exit
end

DECOR_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

139

DEM_BAD_DATA_DOIT
Use this program to correct bad data points and/or areas in digital elevation data
(DEM). Bad data points are defined by a mask band, bad data value, minimum
threshold, and/or maximum threshold. The results from these optional keywords are
ORd together to form the overall bad data mask. At least one of the methods for
specifying bad data must be defined.

Syntax
ENVI_DOIT, DEM_BAD_DATA_DOIT

Keywords
BAD_VALUE (optional)
Use this keyword to specify a bad DEM value. All DEM values equal to
BAD_VALUE are considered bad values. BAD_VALUE is a single number.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.
ENVI Reference Guide

DEM_BAD_DATA_DOIT

140

Chapter 2: ENVI Routines

M_FID (optional)
Use this keyword to specify the file ID for the bad data mask file. Mask pixels not
equal to zero are considered bad data. This is the value returned from the keyword
R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer, with a value
greater than zero. An invalid file ID is specified as -1.

M_POS (optional)
Use this keyword to specify the band position of the bad data-mask band. Mask
pixels not equal to zero are considered bad data. M_POS is a single long value greater
than or equal to zero.

MAX_THRESH (optional)
Use this keyword to specify the maximum threshold for bad DEM values. Values less
than or equal to this threshold are considered bad data. MAX_THRESH is a single
number. When used in conjunction with MIN_THRESH values between both
thresholds are considered bad.

MIN_THRESH (optional)
Use this keyword to specify the minimum threshold for bad DEM values. Values
greater than or equal to this threshold are considered bad data. MIN_THRESH is a
single number. When used in conjunction with MAX_THRESH values between both
thresholds are considered bad.

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

DEM_BAD_DATA_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

141

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

See Also
TOPO_DOIT

ENVI Reference Guide

DEM_BAD_DATA_DOIT

142

Chapter 2: ENVI Routines

DESKEW_DOIT
Use this program to deskew Landsat MSS data for earth rotation.

Syntax
ENVI_DOIT, DESKEW_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

LATD
Set this keyword to a long integer specifying the latitude degrees for Landsat Scene
center.

DESKEW_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

143

LATM
Set this keyword to a long integer specifying the latitude minutes for Landsat Scene
center.

LATS
Set this keyword to a long integer specifying the latitude seconds for Landsat Scene
center.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_deskew_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid

ENVI Reference Guide

DESKEW_DOIT

144

Chapter 2: ENVI Routines


if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; image deskew on all samples and
; bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Deskew the image
;
envi_doit, deskew_doit, $
fid=fid, pos=pos, dims=dims, $
latd=44, latm=13, lats=0, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

DESKEW_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

145

DESTRIPE_DOIT
Use this program to destripe image data for detector imbalance.

Syntax
ENVI_DOIT, DESTRIPE_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

NUM_DET
Use this keyword to specify the number of detectors in the instrument. Set equal to 16
for TM, or equal to 6 for MSS.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

ENVI Reference Guide

DESTRIPE_DOIT

146

Chapter 2: ENVI Routines

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_destripe_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; destriping on all samples and bands
; in the file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Perform the image destriping

DESTRIPE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

147

;
envi_doit, destripe_doit, $
fid=fid, pos=pos, dims=dims, $
num_det=16, out_name=out_name, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

DESTRIPE_DOIT

148

Chapter 2: ENVI Routines

DISP_GET_LOCATION
Use this routine to return the x and y locations of the current pixel for a given ENVI
display. Pixel locations are returned in modified file coordinate system: pixel coord =
file coord + (xy)start - 1, where (xy)start is the xstart or ystart value in the ENVI
header for the displayed image.
Note
An interactive ENVI session is required to run this routine.

Syntax
DISP_GET_LOCATION

Arguments
DN
The display number corresponding to an open display.

XFLOC
Upon return, this variable contains the x location of the current pixel, in modified file
coordinates.

YFLOC
Upon return, this variable contains the y location of the current pixel, in modified file
coordinates.

Keywords
FLOATING (optional)
Set this keyword if you want the XFLOC and YFLOC coordinates to be returned as
floating point values. If this keyword is not set, then XFLOC and YFLOC will be
long integer values.

NO_OFFSET (optional)
Set this keyword to return the current pixel location in ordinary zero-based file
coordinates (without (xy) start values being added).
DISP_GET_LOCATION

ENVI Reference Guide

Chapter 2: ENVI Routines

149

Example
;
; This example prints out the location of
; the current pixel for each display
;
pro example_disp_get_location
;
; Get all the display numbers and
; check to make sure at least one
; display is present.
;
display = envi_get_display_numbers()
if (display[0] eq -1) then return
;
; Print out the location of the
; current pixel for each display
;
for i=0, n_elements(display)-1 do begin
disp_get_location, display[i], xloc, yloc
print, display[i], xloc, yloc
endfor
end

See Also
DISP_GOTO
ENVI_DISP_QUERY

ENVI Reference Guide

DISP_GET_LOCATION

150

Chapter 2: ENVI Routines

DISP_GOTO
Use this routine to move the current pixel of a given display. The Zoom window will
also be moved, so that it is centered on the new current pixel location. If the new
current pixel location is not within the current Image window, the Image and Scroll
windows will also be moved, so that they include the new current pixel.
Note
An interactive ENVI session is required to run this routine.

Syntax
DISP_GOTO, DN, XFLOC, YFLOC

Arguments
DN
The display number corresponding to an open display.

XFLOC
Upon return, this variable contains the x location of the new current pixel, in zerobased file coordinates.

YFLOC
Upon return, this variable contains the y location of the new current pixel, in zerobased file coordinates.

Keywords
NO_WARN (optional)
Set this keyword, if you do not want an error message printed when the XFLOC,
YFLOC location is invalid for the currently displayed image. For example, if the
image is 512 x 512 and you specify (700,700), an error message will be printed,
unless /NO_WARN is set.

DISP_GOTO

ENVI Reference Guide

Chapter 2: ENVI Routines

151

Example
;
; This example move the current pixel in
; the first display by ten pixels in X and Y.
;
pro example_disp_goto
;
; Get all the display numbers and
; check to make sure at least one
; display is present.
;
display = envi_get_display_numbers()
if (display[0] eq -1) then return
;
; Move the first display ten pixels
; in X and Y.
;
disp_get_location, display[0], xloc, yloc
disp_goto, display[0], xloc+10, yloc+10
end

See Also
DISP_GET_LOCATION
ENVI_DISP_QUERY

ENVI Reference Guide

DISP_GOTO

152

Chapter 2: ENVI Routines

DISP_OUT_IMG
Use this program to output an image to a PostScript file.
Note
An interactive ENVI session is required to run this routine.

Syntax
DISP_OUT_IMG

Keywords
ANN_COLOR (optional)
Use this optional keyword to specify the grayscale level for graphical overlays when
outputting to grayscale. ANN_COLOR is a single integer value from, 0 to 255
(inclusive). The default is zero.

ANN_NAMES (optional)
Use this optional keyword to specify an array of saved annotation file names. Each of
these annotation files will be overlaid on the output image.

BORDER (optional)
Use this optional keyword to specify a two-element array of X and Y border sizes (in
inches).

BPP (optional)
Use this optional keyword to specify the number of bits per pixel in the PostScript
output. Valid values are 1, 2, 4, or 8.

COLOR
Set this keyword for color output, otherwise set to zero.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:
DISP_OUT_IMG

ENVI Reference Guide

Chapter 2: ENVI Routines

153

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify an array of file IDs.

LAND
Set this keyword for landscape output, otherwise set to zero for portrait output.

OUT_NAME
Use this keyword to specify an output file name for the resulting PostScript file.

POS
Use this keyword to specify an array of band positions for each of the files specified
by the FID array.

PSIZE
Use this keyword to specify a two-element array indicating the paper size in inches
(e.g. [8.5, 11]).

REBIN
Use this keyword to specify a REBIN factor to apply to the data. Values less than one
enlarge the data, and values greater than one reduce the data.

XOFF
Use this keyword to specify the X offset (in inches) from the left side of the output.

XSIZE
Use this keyword to specify the X size of the output.

YOFF
Use this keyword to specify the Y offset (in inches) from the top of the output.

ENVI Reference Guide

DISP_OUT_IMG

154

Chapter 2: ENVI Routines

YSIZE
Use this keyword to specify the Y size of the output.

Example
pro example_disp_out_img
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS keyword to process
; all spatial data and set the POS
; keyword to select the first band
; in the file.
;
envi_file_query, fid, ns=ns, nl=nl
dims = [-1, 0, ns-1, 0, nl-1]
pos = [0]
;
; Call the output routine.
;
disp_out_img, $
fid=fid, dims=dims, pos=pos, $
bpp=8, color=0, land=0, psize=[8.5,11], $
out_name=test.ps, rebin=1., $
xoff=.25, yoff=.25, xsize=5., ysize=5.
;
; Exit ENVI
;
envi_batch_exit
end

DISP_OUT_IMG

ENVI Reference Guide

Chapter 2: ENVI Routines

155

ELINE_CAL_DOIT
Use this program to spectrally calibrate an image using the Empirical Line method.

Syntax
ENVI_DOIT, ELINE_CAL_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

ENVI Reference Guide

ELINE_CAL_DOIT

156

Chapter 2: ENVI Routines

PATH_RAD
Use this keyword to specify an array of Path Radiance values. There is one value for
each band in the POS array.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

SOLAR_IRR
Use this keyword to specify an array of Maximum Solar Irradiance values. There is
one value for each band in the POS array.

Example
pro example_eline_cal_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; emperical line calibration on all
; samples and all bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb

ELINE_CAL_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

157

dims = [-1, 0, ns-1, 0, nl-1]


pos = lindgen(nb)
out_name = testimg
path_rad = [2.00, 1.33, 1.20, $
1.11, 2.60, 3.12]
solar_irr = [2.33, 4.10, 6.00, $
1.55, 5.32, 4.05]
;
; Perform the emperical line calibration
;
envi_doit, eline_cal_doit, $
fid=fid, pos=pos, dims=dims, $
path_rad=path_rad, $
solar_irr=solar_irr, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

ELINE_CAL_DOIT

158

Chapter 2: ENVI Routines

EMITTANCE_CALC_DOIT
Use this program to convert data to emissivity, using either Reference Channel
Emissivity, Emissivity Normalization, or Alpha Residuals. Using the keywords
DATA_SCALE and WL_SCALE input data and wavelengths can be converted on the
fly to W/m2/um/sr and um, respectively. Optionally, a temperature image can be output
when using the Reference Channel Emissivity or Emissivity Normalization method.

Syntax
ENVI_DOIT, EMITTANCE_CALC_DOIT

Keywords
CONSTANT_BAND (optional)
Use this keyword to specify the band position of the constant band used in the
Reference Channel method. CONSTANT_BAND is a single long value ranging from
zero to number of bands -1. CONSTANT_BAND is not used for the other methods.

DATA_SCALE
Use this keyword to specify the scale factor applied to the data, prior to calculating
the emissivity. DATA_SCALE converts the input data to W/m2/um/sr.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

EMISSIVITY_VALUE (optional)
Use this keyword to specify the assumed emissivity value. EMISSIVITY_VALUE is
only used for METHOD equal to 0 or 1.
EMITTANCE_CALC_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

159

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

METHOD
Set this keyword equal to one of the following values, to specify the algorithm for
calculating the image data emissivity.

0 Reference Channel

1 Emissivity Normalization

2 Alpha Residuals

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

TEMP_OUT_NAME (optional)
Use this keyword to specify an output filename for the temperature image. If this item
is present, the temperature image is automatically saved. TEMP_OUT_NAME is
only valid for METHOD equal 0 or 1.
ENVI Reference Guide

EMITTANCE_CALC_DOIT

160

Chapter 2: ENVI Routines

TEMP_IN_MEMORY (optional)
Set this keyword to specify that output temperature images should be stored in
memory. TEMP_OUT_NAME is only valid for METHOD equal 0 or 1.

WL_SCALE
Use this keyword to specify the scale factor applied to the wavelengths, prior to
calculating the emissivity. WL_SCALE converts the input wavelength to um.

See Also
TIMS_CAL_DOIT

EMITTANCE_CALC_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

161

ENVI
This procedure is used to restore the base ENVI save files for Batch mode. To restore
the base save files, use the keyword RESTORE_BASE_SAVE_FILES.

Syntax
ENVI

Keywords
RESTORE_BASE_SAVE_FILES
Use this keyword to restore the base ENVI save files. After calling this routine, batch
processing can be initialized by ENVI_BATCH_INIT.

Example
This example restores the ENVI base save files and initializes ENVI for batch
processing.
ENVI, /RESTORE_BASE_SAVE_FILES
ENVI_BATCH_INIT, LOG_FILE = batch_log.txt, BATCH_LUN = lunit

See Also
ENVI_BATCH_EXIT
ENVI_BATCH_INIT

ENVI Reference Guide

ENVI

162

Chapter 2: ENVI Routines

ENVI_ADD_PROJECTION
Use this procedure to update the ENVI projections.

Syntax
ENVI_ADD_PROJECTION, Proj

Keywords
NAME (optional)
Use this optional keyword to specify the output file to write, including the directory
path. The default is to use map_proj.txt in the map_proj directory of the
installation tree. NAME is a string.

WRITE (optional)
Set this optional keyword to update the map projection file. The default is to add the
projection to the current ENVI session and not save the projection to a file.

ENVI_ADD_PROJECTION

ENVI Reference Guide

Chapter 2: ENVI Routines

163

ENVI_ASSIGN_HEADER_VALUE
Use this procedure to set user defined header values. User defined header values are
in addition to the standard ENVI header keywords set using ENVI_SETUP_HEAD
or ENVI_ENTER_DATA. User defined header values use the same keyword =
value(s) format as the standard ENVI header values.
Warning
The user defined keywords can be any string values but must not conflict with the
standard ENVI header keywords. See ENVI Header Format of the ENVI Users
Guide for a list.
To add user defined keywords to an ENVI file, first set the keyword value using
ENVI_ASSIGN_HEADER_VALUE. After setting all new user header values use the
routine ENVI_WRITE_FILE_HEADER to write out the new ENVI header to disk.
The new header file will contain all the current ENVI header keywords plus the
newly defined user header values.

Syntax
ENVI_ASSIGN_HEADER_VALUE

Keywords
FID
The file ID for the open file. This is the value returned from the keyword R_FID in
the ENVI_OPEN_FILE procedure. FID is a long integer with a value greater than
zero. An invalid file ID is specified as 1.

KEYWORD
The user defined keyword string. KEYWORD is a case insensitive string value
defining the user defined keyword. The value of KEYWORD cannot conflict with the
standard ENVI header keywords. See ENVI Header Format in Appendix B of the
ENVI Users Guide for a list.

PRECISION (optional)
Use this optional keyword to specify the number of digits to the right of the decimal
point when saving floating point, double precision, and complex types for user
defined header values. The default is to use four decimal places, PRECISION = 4.
ENVI Reference Guide

ENVI_ASSIGN_HEADER_VALUE

164

Chapter 2: ENVI Routines

Note
Use care to avoid loss of precision since the header values are stored as ASCII
strings.

SCIENTIFIC_NOTATION (optional)
If set, the string of the number is stored in scientific notation rather than standard
floating point notation. The precision of the output string can be specified with the
PRECISION keyword.

VALUE
The user defined keyword values. VALUE can be a single element or an array of byte
(8-bits), integer (16-bits), long integer (32-bits), floating-point (32-bits), doubleprecision floating point (64-bits), complex (2x32-bits), string, double-precision
complex (2x64-bits), unsigned integer (16-bits), unsigned long integer (32-bits), long
64-bit integer, or unsigned long 64-bit integer values. For floating point, double
precision, and complex numbers the keyword PRECISION is used to define the
number of decimal points to output to the file header.

Example
The following example will open the image file can_tmr.img using the
ENVI_OPEN_FILE routine. Once the file is open and a valid file ID is returned, a
user defined header value for My Scale Factors is stored to the header using
ENVI_ASSIGN_HEADER_VALUE. The new header field is queried using
ENVI_GET_HEADER_VALUE with the keyword to return floating point values.
The returned result is printed to the ENVI log window. At this point the header
change exists only in the current ENVI session. In order to preserve this change to the
disk file the routine ENVI_WRITE_FILE_HEADER is called to write an updated
header to disk.
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then return
scale_factors = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
envi_assign_header_value, fid=fid, keyword=My Scale Factors, $
value=scale_factors, precision=3
values = envi_get_header_value(fid, My Scale Factors, /float)

ENVI_ASSIGN_HEADER_VALUE

ENVI Reference Guide

Chapter 2: ENVI Routines

165

print, My Scale Factors, values


envi_write_file_header, fid

See Also
ENVI_GET_HEADER_VALUE
ENVI_WRITE_FILE_HEADER

ENVI Reference Guide

ENVI_ASSIGN_HEADER_VALUE

166

Chapter 2: ENVI Routines

ENVI_AUTO_TIE_POINTS_DOIT
This routine automatically calculates tie points for two images, which makes fully
automatic image registration possible. The tie points can be used by
ENVI_REGISTER_DOIT to co-register the two images.
Two matching algorithms are used to obtain tie points: area-based matching, and
feature-based matching.

Area-based matching Compares the grayscale values of patches of two or


more images and tries to find conjugate image locations based on similarity in
the grayscale value patterns.

Feature-based matching Extracts distinct features from the images


independently, and then identifies corresponding features by comparing
feature attributes and consistency in the location of corresponding features.

Syntax
Area-based matching:
ENVI_DOIT, 'ENVI_AUTO_TIE_POINTS_DOIT' [, AREA_CHIP_SIZE=value] ,
BASE_FID=fileID [, BASE_MATCH_POS=value]
[, IN_TIE_POINTS_ARRAY=array] [, INTEREST_OPERATOR=value]
[, MATCH_METHOD={0, 1}] [, MIN_CORRELATION=value]
[, MOVE_WIN=value] [, NUM_OVERSAMPLES=value]
[, NUM_TIE_POINTS=value] [, OUT_TIE_POINTS_ARRAY=array]
[, OUT_TIE_POINTS_NAME=string] [, SEARCH_WIN=value],
WARP_FID=fileID [, WARP_MATCH_POS=value]
Feature-based matching:
ENVI_DOIT, 'ENVI_AUTO_TIE_POINTS_DOIT', BASE_FID=fileID
[, BASE_OVERLAY_DIMS=value] [, BASE_MATCH_POS=value]
[, IN_TIE_POINTS_ARRAY=array] [, MATCH_METHOD={0, 2}]
[, MAX_MATCH_LEVEL=value] [, NUM_MATCH_LEVELS=value]
[, OUT_TIE_POINTS_ARRAY=array] [, OUT_TIE_POINTS_NAME=string]
[, PIXEL_SIZE_RATIO=value] [, RELIABILITY_CHECK=value] ,
WARP_FID=fileID [, WARP_MATCH_POS=value]
[, WARP_OVERLAY_DIMS=array]

Arguments
None
ENVI_AUTO_TIE_POINTS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

167

Keywords
AREA_CHIP_SIZE (optional)
Use this optional keyword to specify an integer value for one side of a square image
chip size for finding the Moravec or Frstner interest points in the base image. Larger
values require more computational time; however, the tie points obtained may be
more useful. The default is 128, meaning a 128 x 128 image chip size. Area-based
matching only.

BASE_FID
Use this keyword to specify the file ID of the base image. This is the value returned
from the R_FID keyword in the ENVI_OPEN_FILE procedure. BASE_FID is a long
integer with a value greater than zero. An invalid file ID is specified as 1.

BASE_OVERLAY_DIMS (optional)
Use this optional keyword to specify the spatial dimensions on the base image that
overlap with the warp image. This information enables you to achieve better results
for feature-based matching. If both the base image and the warp image have map
information, the maximum overlapping region of the base image is taken as the
default dimension. Otherwise, the image dimension of the base image is taken as the
default dimension. Feature-based matching only.
The BASE_OVERLAY_DIMS keyword is set to a five-element array of long
integers with the following definitions:
Array Element

Description

BASE_OVERLAY_DIMS[0]

Unused for this function. Set to 1.

BASE_OVERLAY_DIMS[1]

The starting X pixel.


Note - The first pixel is number zero.

BASE_OVERLAY_DIMS[2]

The ending X pixel.

BASE_OVERLAY_DIMS[3]

The starting Y pixel.


Note - The first pixel is number zero.

ENVI Reference Guide

ENVI_AUTO_TIE_POINTS_DOIT

168

Chapter 2: ENVI Routines

Array Element
BASE_OVERLAY_DIMS[4]

Description
The ending Y pixel.

BASE_MATCH_POS (optional)
Use this optional keyword to specify a band number from the base image on which to
perform image matching. This keyword is a long integer, ranging from 0 to the
number of bands minus 1. The default is 0 (the first band).

IN_TIE_POINTS_ARRAY (optional)
Use this optional keyword to store three or more seed tie points to guide the image
matching process. The keyword is a (4, n) floating-point array, where the four
columns are X1, Y1 (the base image coordinates) and X2, Y2 (the warp image
coordinates), and n is the number of tie points.

INTEREST_OPERATOR (optional)
Set this optional keyword to specify the operator type to use for identifying point
features. It can be either 0 (Moravec operator) or 1 (Frstner). The default is 0. Areabased image matching only.

MATCH_METHOD (optional)
Use this optional keyword to specify an integer indicating the matching method to
use. The default is 0.
The following table shows the values that represent how the matching method is
used.
Value

Description

The match method used is automatically decided by ENVI. If


the IN_TIE_POINTS_ARRAY keyword is set, or both the base
image and warp image have map info (or RPC or pseudo map
info), then area-based matching is used. Otherwise, featurebased matching is used.

Force to use area-based matching.

ENVI_AUTO_TIE_POINTS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

169

Value
2

Description
Force to use feature-based matching.

MAX_MATCH_LEVEL (optional)
Use this optional keyword to specify the maximum image dimension on which to
extract feature points and perform matching. A value of n indicates that the maximum
image dimension on which to extract feature points is the original image dimension
divided by 2n. A value of 0 (default) means that the extraction and matching of
feature points are performed on the full-resolution base image. The default value is an
image pyramid level that is close to an image size of 512 x 512. Feature-based
matching only.
Note
Smaller values for this keyword result in more feature points being extracted,
giving more accurate results; however, the process requires significantly more time.
For large image sizes, select a larger MAX_MATCH_LEVEL value so that image
matching can be completed in a relatively shorter period of time.

MIN_CORRELATION (optional)
Use this optional keyword to specify a floating-point value to use for the minimum
correlation coefficient. Any matches with a correlation coefficient smaller than this
keyword value are discarded. The default is 0.70. Area-based matching only.

MOVE_WIN (optional)
Use this optional keyword to specify an integer that is one side of a square area
defining the moving window size. The default is 11, meaning an moving window size
of 11 x 11. Area-based matching only.

NUM_MATCH_LEVELS (optional)
Use this optional keyword to specify an integer value for the number of scale space
levels for extracting feature points. The default is 1. Feature-based matching only.
Larger values require more time for matching; however more feature points are
generated. If this keyword is set greater than one, the matching is performed starting
from the image pyramid level determined by MAX_MATCH_LEVEL, and
continuing upward along the image pyramid until NUM_MATCH_LEVEL is
reached.
ENVI Reference Guide

ENVI_AUTO_TIE_POINTS_DOIT

170

Chapter 2: ENVI Routines

Figure 7-1 shows an example of an image pyramid with a base image size of 2048 x
2048. If MAX_MATCH_LEVEL is set to 1 and NUM_MATCH_LEVELS is set to 2,
then matching is conducted on two levels: 1024 x 1024 and 512 x 512. The matching
process stops, however, if the image size of a pyramid level is smaller than 64 x 64.
In that case, the actual number of match levels used may be smaller than the value of
NUM_MATCH_LEVELS set by the user.

Figure 7-1: Image Pyramid Illustrating Matching Levels

NUM_OVERSAMPLES (optional)
Set this optional keyword to an integer specifying the number of over-samples.
Larger values require more processing time, but result in increased reliability. The
default value is 1. Area-based matching only.

NUM_TIE_POINTS (optional)
Use this optional keyword to specify an integer value for the number of tie points to
generate. The default is 25. Area-based matching only.

OUT_TIE_POINTS_ARRAY (optional)
Use this optional keyword to specify a named variable for storing auto-generated tie
points. This is a (4, npts) floating-point array, where the four columns are the
coordinates of the base and warp images, and npts is the number of tie points. The
values use 0-based indexing.

ENVI_AUTO_TIE_POINTS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

171

OUT_TIE_POINTS_NAME (optional)
Use this optional keyword to specify an output filename in which to store the tie
points. The values use 1-based indexing.

PIXEL_SIZE_RATIO (optional)
Use this optional keyword to specify a floating-point value for the ratio of the warp
image pixel size to the base image pixel size. This is used as a guide in the feature
matching process. The default is 1.0. Feature-based matching only.

RELIABILITY_CHECK (optional)
Set this optional keyword to either 0 (false) or 1 (true) to specify whether some
matches are removed based on certain secondary reliability measurements. The
default is 1 (true). Feature-based matching only.
Setting this keyword to 1 results in fewer, yet more reliable tie points. Setting this
keyword to 0 results in more tie points which are not as reliable. Typically, most
remote sensing imagery applications will use the default setting of 1. However, in
certain cases, you may want to set RELIABILITY_CHECK to 0 to extract as many
tie points as possible; which will be at the expense of the output tie point reliability.

SEARCH_WIN (optional)
Set this optional keyword to an integer value representing one side of a square area
specifying the search window size. Using larger values makes it more likely that the
correct match may be found; however, more computational time is required for these
conditions. The default is 81, meaning the search window size is 81 x 81. Areabased matching only.

WARP_FID
Use this keyword to specify the file ID for the input warp image file. This input warp
file ID is the value returned from the R_FID keyword in the ENVI_OPEN_FILE
procedure. WARP_FID is a long integer with a value greater than zero. An invalid
file ID is specified as 1.

WARP_MATCH_POS (optional)
Use this optional keyword to specify a single band position from the input warp
image on which to perform image matching. WARP_MATCH_POS is a long integer,
ranging from zero to the number of bands minus 1. The default is 0 (the first band).

ENVI Reference Guide

ENVI_AUTO_TIE_POINTS_DOIT

172

Chapter 2: ENVI Routines

WARP_OVERLAY_DIMS (optional)
Use this optional keyword to specify the spatial dimensions of the warp image that
overlap with the base image. If both the base image and the warp image have map
information, the maximum overlapping region of the warp image is taken as the
default dimension. Otherwise, the image dimension of the warp image is taken as the
default dimension. Feature-based matching only.
The WARP_OVERLAY_DIMS keyword is a five-element array of long integers with
the following definitions:
Array Element

Description

WARP_OVERLAY_DIMS[0]

Unused for this function, set to 1.

WARP_OVERLAY_DIMS[1]

The starting X pixel.


Note - The first pixel is number zero.

WARP_OVERLAY_DIMS[2]

The ending X pixel.

WARP_OVERLAY_DIMS[3]

The starting Y pixel.


Note - The first pixel is number zero.

WARP_OVERLAY_DIMS[4]

The ending Y pixel.

Examples
Example 1
In this example, area-based matching is performed on an image with three known tie
points.
pro example1_auto_tie_points_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;

ENVI_AUTO_TIE_POINTS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

173

envi_batch_init, log_file=batch.txt
;
; Open the input files
;
envi_open_file, bldr_sp.img, r_fid=base_fid
envi_open_file, bldr_tm.img, r_fid=warp_fid
if (base_fid eq -1 || warp_fid eq -1) then begin
envi_batch_exit
return
endif
;
;Set the IN_TIE_POINTS_ARRAY, BASE_MATCH_POS, WARP_MATCH_POS,
; MATCH_METHOD, OUT_TIE_POINTS_NAME, NUM_TIE_POINTS, MOVE_WIN,
; SEARCH_WIN, NUM_OVERSAMPLES, and AREA_CHIP_SIZE keywords to
; process
;
in_tie_points_array = $
[[285.000000, 255.000000, 133.250000, 263.500000], $
[836.000000, 223.000000, 322.500000, 218.500000], $
[529.000000, 1222.00000, 280.250000, 583.250000]]
base_match_pos = 0L
warp_match_pos = 0L
match_method = 1
num_tie_points = 25
move_win = 11
search_win = 81
area_chip_size = 128L
num_oversamples = 4
out_tie_points_name = out_tie_points1.pts
;
; Perform the automatic tie point collection
;
envi_doit, envi_auto_tie_points_doit, base_fid=base_fid, $
warp_fid=warp_fid, base_match_pos=base_match_pos, $
warp_match_pos=warp_match_pos, match_method=match_method, $
num_tie_points=num_tie_points, move_win=move_win, $
search_win=search_win, area_chip_size=area_chip_size, $
in_tie_points_array=in_tie_points_array, $
num_oversamples=num_oversamples, $
out_tie_points_name=out_tie_points_name
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

ENVI_AUTO_TIE_POINTS_DOIT

174

Chapter 2: ENVI Routines

Example 2
Feature-based matching is shown in this example.
pro example2_auto_tie_points_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input files
;
envi_open_file, sample1.img, r_fid=base_fid
envi_open_file, sample2.img, r_fid=warp_fid
if (base_fid eq -1 || warp_fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the BASE_MATCH_POS, WARP_MATCH_POS, MATCH_METHOD,
; MAX_MATCH_LEVEL, PIXEL_SIZE_RATIO, and OUT_TIE_POINTS_NAME
; keywords to process.
base_match_pos = 0L
warp_match_pos = 0L
match_method = 2
max_match_level = 3
pixel_size_ratio = 1.0
out_tie_points_name = out_tie_points2.pts
;
; Perform the automatic tie points collection
;
envi_doit, envi_auto_tie_points_doit, base_fid=base_fid, $
warp_fid=warp_fid, base_match_pos=base_match_pos, $
warp_match_pos=warp_match_pos, match_method=match_method, $
pixel_size_ratio=pixel_size_ratio, $
max_match_level=max_match_level, $
out_tie_points_name=out_tie_points_name
;
; Exit ENVI
;
envi_batch_exit
end

ENVI_AUTO_TIE_POINTS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

175

See Also
ENVI_REGISTER_DOIT

ENVI Reference Guide

ENVI_AUTO_TIE_POINTS_DOIT

176

Chapter 2: ENVI Routines

ENVI_AVHRR_CALIBRATE_DOIT
Use this program to calibrate AVHRR data or compute AVHRR Sea Surface
Temperature (SST). The input to this routine must be an AVHRR level 1b or KLM
file. The information in the file header is used for the calibration and SST
calculations.

Syntax
ENVI_DOIT, ENVI_AVHRR_CALIBRATE_DOIT

Keywords
CALC_SST (optional)
Set this keyword to output the Sea Surface Temperature (SST) instead of the
calibrated data. If CALC_SST is set, you must also specify METHOD. The default is
to not compute SST.

CORRECT_SOLARZ (optional)
Set this keyword to allow correction for the solar zenith angle. The default is to not
correct for the solar zenith angle.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]:Unused for this function, set to -1.

DIMS[1]:The starting X pixel. (The first pixel is number zero.)

DIMS[2]:The ending X pixel.

DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

DIMS[4]:The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.
ENVI_AVHRR_CALIBRATE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

177

IN_MEMORY (optional)
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

METHOD (optional)
Use this keyword to specify the algorithm for the SST calculation. If METHOD is set
you must also set CALC_SST. METHOD is an integer number with one of the
following values:

0:Day MCSST Split

1:Night MCSST Split

2: Night MCSST Dual

3: Night MCSST Triple

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_envi_avhrr_calibrate_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;

ENVI Reference Guide

ENVI_AVHRR_CALIBRATE_DOIT

178

Chapter 2: ENVI Routines


; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the data and class files
;
envi_open_data_file, avhrr_file, $
r_fid=fid, /avhrr
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1l, 0, ns-1, 0, nl-1]
out_name = testimg
pos = lindgen(nb)
;
; Call the doit
;
envi_doit, envi_avhrr_calibrate_doit, $
fid=fid, dims=dims, pos=pos, $
out_name=out_name, /correct_solarz, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

See Also
ENVI_AVHRR_GEOMETRY_DOIT

ENVI_AVHRR_CALIBRATE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

179

ENVI_AVHRR_GEOMETRY_DOIT
Use this program to compute the AVHRR geometry (latitude and longitude), solar
zenith angles, and sensor zenith angles for each pixel. The input to this routine must
be an AVHRR level 1b or KLM file. The information in the file header is used to
compute the AVHRR geometry.

Syntax
ENVI_DOIT, ENVI_AVHRR_GEOMETRY_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]:Unused for this function, set to -1.

DIMS[1]:The starting X pixel. (The first pixel is number zero.)

DIMS[2]:The ending X pixel.

DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

DIMS[4]:The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY (optional)
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

ENVI Reference Guide

ENVI_AVHRR_GEOMETRY_DOIT

180

Chapter 2: ENVI Routines

METHOD
Use this keyword to specify which of the output bands to calculate. METHOD is a
four element array of ones and zeros, where a one indicates that the corresponding
output band should be calculated. METHOD has the following definitions:

METHOD[0] - Compute the latitude of each pixel

METHOD[1] - Compute the longitude of each pixel

METHOD[2] - Compute the solar zenith angle of each pixel

METHOD[3] - Compute the sensor zenith angle of each pixel

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired.

OUT_DT
Use this keyword to specify the output data type as either floating-point or doubleprecision. OUT_DT is a long integer that uses the IDL data type conventions:

4 = floating-point (32-bits)

5 = double-precision floating-point (64-bits)

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

RADIANS (optional)
Set this keyword to specify that the output zenith angles are in units of Radians. The
default is to use units of Degrees.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_envi_avhrr_geometry_doit
;
; First restore all the base save files.
;

ENVI_AVHRR_GEOMETRY_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

181

envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the data and class files
;
envi_open_data_file, avhrr_file, $
r_fid=fid, /avhrr
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords
;
envi_file_query, fid, ns=ns, nl=nl
dims = [-1l, 0, ns-1, 0, nl-1]
out_name = testimg
method = [1,1,1,1]
out_bname = [Latitude, $
Longitude, $
Solar Zenith, $
Sensor Zenith]
;
; Call the doit
;
envi_doit, envi_avhrr_geometry_doit, $
fid=fid, dims=dims, out_name=out_name, $
out_dt=4, method=method, $
out_bname=out_bname, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

See Also
ENVI_AVHRR_CALIBRATE_DOIT

ENVI Reference Guide

ENVI_AVHRR_GEOMETRY_DOIT

182

Chapter 2: ENVI Routines

ENVI_AVHRR_WARP_DOIT
Use this program to warp AVHRR data or resulting AVHRR data products. This
routine requires the FID of the file to warp and the corresponding AVHRR FID of the
original data set. For example, you can warp a calibrated image cube or an AVHRR
Sea Surface Temperature image by specifying the FID of the product and the FID of
the original AVHRR data set. In order to warp a raw AVHRR data set, you supply the
same file id. The original AVHRR data set must be an AVHRR level 1b or KLM file.
The information in the file header is used to compute the warp points.

Syntax
ENVI_DOIT, ENVI_AVHRR_WARP_DOIT

Keywords
AVHRR_FID
Use this keyword to specify the file ID for the original AVHRR data set, either an
AVHRR Level 1b or KLM formatted file. This is the value returned from the
keyword R_FID in the ENVI_OPEN_DATA_FILE procedure (make sure to set the
keyword AVHRR when you call ENVI_OPEN_DATA_FILE). FID is a long integer
with a value greater than zero. An invalid file ID is specified as 1.

BACKGROUND
Use this keyword to specify the output image background value.

DEGREE
Use this keyword to specify the degree of the warp to perform.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. This keyword is not needed when the METHOD keyword value is 0, 1, 2,
6, 7, or 8. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]:Unused for this function, set to -1.

DIMS[1]:The starting X pixel. (The first pixel is number zero.)

DIMS[2]:The ending X pixel.

ENVI_AVHRR_WARP_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

183

DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

DIMS[4]:The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

GCP_OUT_NAME (optional)
Use this keyword to specify the output filename for the warp-points filename.
GCP_OUT_NAME is a single string specifying an output filename.

GRID
Use this keyword to specify the number of points in the X and Y warping grid. GRID
is a two element long array specifying the number of X and Y points (respectively)
used to form an equally-spaced set of warp points.

IN_MEMORY (optional)
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

METHOD
Set this keyword to the warping method to use. METHOD is an integer set to one of
the following;

0 RST with nearest neighbor

1 RST with bilinear

2 RST with cubic convolution

3 Polynomial with nearest neighbor

4 Polynomial with bilinear

5 Polynomial with cubic convolution

6 Triangulation with nearest neighbor

7 Triangulation with bilinear

8 Triangulation with cubic convolution

ENVI Reference Guide

ENVI_AVHRR_WARP_DOIT

184

Chapter 2: ENVI Routines

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

PIXEL_SIZE
Use this keyword to specify the X and Y pixel size. PIXEL_SIZE is a two-element
double precision array of the output X and Y pixel sizes, respectively.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

PROJ
Use this keyword to specify the projection for the warped file. PROJ is a projection
structure returned from ENVI_GET_PROJECTION or ENVI_PROJ_CREATE.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

ZERO_EDGE (optional)
Set this keyword to specify that the edges outside of any triangles be set to the value
specified by BACKGROUND. The keyword is only used for Triangulation,
METHOD 6, 7, or 8.

Example
forward_function envi_proj_units_translate, $
envi_proj_create
pro example_envi_avhrr_warp_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files

ENVI_AVHRR_WARP_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

185

;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the data and class files
;
envi_open_data_file, avhrr_file, $
r_fid=fid, /avhrr
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
units = envi_proj_units_translate(Degrees)
proj = envi_proj_create(/geographic, unit=units)
ps = [.05,.05]
;
; Call the doit
;
envi_doit, envi_avhrr_warp_doit, fid=fid, $
avhrr_fid=fid, dims=dims, pos=pos, $
out_name=out_name, method=1, degree=1, $
background=0, grid=[5,5], proj=proj, $
pixel_size=ps, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

See Also
ENVI_AVHRR_GEOMETRY_DOIT

ENVI Reference Guide

ENVI_AVHRR_WARP_DOIT

186

Chapter 2: ENVI Routines

ENVI_BANDMAX_SELECT_BANDS
The ENVI_BANDMAX_SELECT_BANDS function performs the BandMax
background suppression algorithm to derive a subset of significant bands using input
target and background spectra. The resulting band subset can be used to highlight
targets and suppress backgrounds in a classification or other analysis.

Syntax
Result = ENVI_BANDMAX_SELECT_BANDS(TargetSpectra, BackgroundSpectra
[, GOOD_BAND_COUNT=variable] [, GOOD_BAND_LIST=variable]
[, SIGNIFICANCE=variable] [, THRESHOLD=value{0 to 1}])

Return Value
Returns an array of band positions that are determined to be best for differentiating
between the target and background spectra. This value can be used as a POS input to
other ENVI processing functions. If no significant bands are found, a value of 1 is
returned.

Arguments
TargetSpectra
An array of one or more spectra representing the input targets.

BackgroundSpectra
An array of one or more spectra representing the input backgrounds. These spectra
must have the same number of bands as the TargetSpectra argument.

Keywords
GOOD_BAND_COUNT (optional)
Use this optional keyword to specify a named variable to contain a scalar value
indicating the number of significant bands found by the BandMax algorithm.

GOOD_BAND_LIST (optional)
Use this optional keyword to specify a named variable to contain an array of zeroes
and ones indicating which bands are determined to be significant by the BandMax
ENVI_BANDMAX_SELECT_BANDS

ENVI Reference Guide

Chapter 2: ENVI Routines

187

algorithm. Each value is set to 0 (indicating this band should be ignored for
processing) or 1 (indicating this band is significant for isolating the targets from the
background data). If no significant bands are found, the variable returned by this
keyword is undefined.

SIGNIFICANCE (optional)
Use this optional keyword to specify a named variable to contain an array of band
significance values. The array returned by this keyword contains floating-point
values ranging from 0 to 1. Each value indicates how well the corresponding band
can be used to differentiate between target and background spectra. If an error is
encountered in the processing, a value of 1 is returned.

THRESHOLD (optional)
Use this optional keyword to specify a floating-point value ranging from 0 to 1. This
value represents the threshold for the minimum significance value used to determine
which bands are returned by this function. The default threshold value is calculated to
select 25% of the input bands, but never less than 6 bands. If an undefined named
variable is specified for this keyword, the default threshold value is returned for that
variable.

Examples
The following example uses the cup95eff.int file in the data directory and the
jpl1.sli file in the spec_lib/jpl_lib directory. Input image wavelengths are
derived from the cup95eff.int file to resample the spectra from the library in the
jpl1.sli file. One resampled spectrum is used as a target and another is used as the
background in the BandMax algorithm.
PRO BandMaxExample
; This example procedure uses the ENVI_BANDMAX_SELECT_BANDS
; function(the BandMax algorithm) to determine a subset of bands
; for the data in the "cup95eff.int" image file that helps to
; differentiate an Alunite target spectrum from a well-ordered
; Kaolinite background spectrum. These spectra are a part of the
; "jpl1.sli" spectral library.
; Find the input image file and query its wavelengths. These
; wavelengths are used to resample the input spectra.
cupriteFile = ENVI_PICKFILE(FILTER = *.int, $
TITLE = Find the "cup95eff.int" File)
IF (cupriteFile EQ ) THEN RETURN
ENVI_OPEN_FILE, cupriteFile, R_FID = cupriteFID
ENVI_FILE_QUERY, cupriteFID, WL = cupriteWLs

ENVI Reference Guide

ENVI_BANDMAX_SELECT_BANDS

188

Chapter 2: ENVI Routines

; Find the input spectral library and query its number of samples
; and wavelengths. The number of samples value is used to access
; specific spectra in the library. The wavelengths are used to
; resample the input spectra.
libFile = ENVI_PICKFILE(FILTER = *.sli, $
TITLE = Find the "jpl1.sli" File)
IF (libFile EQ ) THEN RETURN
ENVI_OPEN_FILE, libFile, R_FID = libFID
ENVI_FILE_QUERY, libFID, NS = libNS, WL = libWLs
; Get spectrum for Alunite (the target) from the input spectral
; library.
libSpectrum3 = ENVI_GET_SLICE(FID = libFID, LINE = 3, $
POS = 0, XS = 0, XE = libNS - 1)
; Resample Alunite spectrum to the wavelengths of the input image.
ENVI_RESAMPLE_SPECTRA, libWLs, libSpectrum3, cupriteWLs, $
targetSpectrum
; Get spectrum for well-ordered Kaolinite (the background) from
; the input spectral library.
libSpectrum83 = ENVI_GET_SLICE(FID = libFID, LINE = 83, $
POS = 0, XS = 0, XE = libNS - 1)
; Resample Kaolinite spectrum to the wavelengths of the input
; image.
ENVI_RESAMPLE_SPECTRA, libWLs, libSpectrum83, cupriteWLs, $
backgroundSpectrum
; Perform the BandMax algorithm on the Alunite target and the
; Kaolinite background to obtain a subset for the input image.
subset = ENVI_BANDMAX_SELECT_BANDS(targetSpectrum, $
backgroundSpectrum)
; Show the resulting subset. This subset can be used as an input to
; the POS keyword of any ENVI processing routine. It will help to
; differentiate the target from the background in the input image.
PRINT, subset
; Exit out of Batch Mode
ENVI_BATCH_EXIT
END

ENVI_BANDMAX_SELECT_BANDS

ENVI Reference Guide

Chapter 2: ENVI Routines

189

This example procedure produces the following subset of band positions:


2

11

14

15

17

18

21

29

30

35

37

It can be applied to the input image through the POS keyword in other ENVI
processing routines to help differentiate the target spectrum from the background
spectrum.

ENVI Reference Guide

ENVI_BANDMAX_SELECT_BANDS

190

Chapter 2: ENVI Routines

ENVI_BATCH_EXIT
Use this routine to exit ENVI from the non-menu batch mode, which is the mode
without the ENVI menu interface. This routine will conclude the ENVI session. If the
ENVI preference Exit IDL on Exit from ENVI is set to Yes, then the IDL session
will also terminate. ENVI_BATCH_EXIT closes the session that was started with
ENVI_BATCH_INIT.
Note
For more information on ENVI preferences, see Setting ENVI Preferences in
Chapter 2 of the ENVI Users Guide.

Syntax
ENVI_BATCH_EXIT

Keywords
EXIT_IDL (optional)
Use this keyword force IDL to exit even if ENVIs preference setting for Exit IDL
on Exit from ENVI is set to No.

NO_CONFIRM (optional)
Use this keyword to override IDLs exit confirmation preference setting.

Example
The following procedure and example code will initialize ENVI in batch mode, set
the log file to batch.txt, print Hello World and exit ENVI:
1. In the procedure use the ENVI command with the keyword
RESTORE_BASE_SAVE_FILES to restore the base ENVI save files.
2. Initialize ENVI in the non-menu batch mode using ENVI_BATCH_INIT.
3. Use the IDL print command to print Hello World.
4. Exit ENVI using the ENVI_BATCH_EXIT command.

ENVI_BATCH_EXIT

ENVI Reference Guide

Chapter 2: ENVI Routines

191

To execute the example routine:


1. Start IDL without starting ENVI.
2. Compile and execute the procedure.
pro example_envi_batch_exit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Print message
;
print, Hello World
;
; Exit ENVI
;
envi_batch_exit
end

See Also
ENVI, ENVI_BATCH_INIT
ENVI_DOIT

ENVI Reference Guide

ENVI_BATCH_EXIT

192

Chapter 2: ENVI Routines

ENVI_BATCH_INIT
Use this routine to initialize ENVI in the non-menu batch mode, which is the mode
without the ENVI menu interface. Many of the ENVI image processing programs
that do not require user interaction were designed to be run in non-menu batch mode.
Warning
Do not attempt to initialize ENVI in batch mode from an IDL session that is
currently running an interactive ENVI session. Instead, start a new IDL session to
initialize ENVI in batch mode.

Syntax
ENVI_BATCH_INIT

Keywords
BATCH_LUN (optional)
Use this keyword to specify a named variable that will contain the logical unit
number of the batch log file.

LOG_FILE (optional)
Use this keyword to specify a batch log file. Any errors or warnings that would
normally appear on the screen during an interactive ENVI session will be written to
the log file. It is important to check your log file after your batch processing routine is
finished, to make sure no errors have occurred. LOG_FILE is a string variable
specifying the filename and path of the batch log file.

NO_STATUS_WINDOW (optional)
Set this optional keyword to prevent display of the ENVI processing status window.
Additional control of the status window can be achieved using
ENVI_BATCH_STATUS_WIDOW.

ENVI_BATCH_INIT

ENVI Reference Guide

Chapter 2: ENVI Routines

193

Example
The following procedure and example code will initialize ENVI in batch mode, set
the log file to batch.txt, print Hello World and exit ENVI:
1. In the procedure use the ENVI command with the keyword
RESTORE_BASE_SAVE_FILES to restore the base ENVI save files.
2. Initialize ENVI in the non-menu batch mode using ENVI_BATCH_INIT.
3. Use the IDL print command to print Hello World.
4. Exit ENVI using the ENVI_BATCH_EXIT command.
To execute the example routine:
1. Start IDL without starting ENVI.
2. Compile and execute the procedure.
pro example_envi_batch_exit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Print message
;
print, Hello World
;
; Exit ENVI
;
envi_batch_exit
end

See Also
ENVI
ENVI_BATCH_EXIT
ENVI_BATCH_STATUS_WINDOW
ENVI_DOIT

ENVI Reference Guide

ENVI_BATCH_INIT

194

Chapter 2: ENVI Routines

ENVI_BATCH_STATUS_WINDOW
Use this routine to enable and disable the ENVI batch status window. The status
window is used to show the progress of the processing routines. The keywords ON
and OFF control whether the window is enabled (ON) or disabled (OFF).
ENVI_BATCH_STATUS_WINDOW allows the user precise control of the status
window and may be used to enable and disable the status window multiple times in a
single batch processing session. In addition, the keyword NO_STATUS_WINDOW
to the ENVI_BATCH_INIT routine controls the initial state of the status window.

Syntax
ENVI_BATCH_STATUS_WINDOW

Keywords
OFF (optional)
Set this optional keyword to prevent display of the ENVI processing status window.

ON (optional)
Set this optional keyword to allow display of the ENVI processing status window.

Example
The following example will run statistics on bhtmref.img with and without the
status window. This example uses the following files found in the data directory of
the ENVI installation:

bhtmref.img

bhtmref.hdr

ENVI_BATCH_STATUS_WINDOW

ENVI Reference Guide

Chapter 2: ENVI Routines

195

First, ENVI is initialized in batch mode with the status window present. The file
bhtmref.img is opened and ENVI_STATS_DOIT is used to perform basic
statistical calculations. During this process, the status window will be displayed.
Next, the status window is turned off and the same statistics processing is performed.
This time, the status window is not displayed. After each statistical calculation the
mean value is printed.
pro example_envi_batch_status_window
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Get the samples, lines and # bands
; for the input file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
;
; Set the dims and pos to calculate
; statistics for all data (spatially and
; spectrally) in the file.
;
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
;
; Calculate the basic statistics and
; print the mean.
;
envi_doit, envi_stats_doit, fid=fid, pos=pos, $
dims=dims, comp_flag=1, mean=mean
print, Mean, mean
;
; Turn off the status window and do the same
;
envi_batch_status_window, /off

ENVI Reference Guide

ENVI_BATCH_STATUS_WINDOW

196

Chapter 2: ENVI Routines


;
; Calculate the basic statistics and
; print the mean.
;
envi_doit, envi_stats_doit, fid=fid, pos=pos, $
dims=dims, comp_flag=1, mean=mean
print, Mean, mean
;
; Exit ENVI
;
envi_batch_exit
end

See Also
ENVI_BATCH_INIT
ENVI_DOIT

ENVI_BATCH_STATUS_WINDOW

ENVI Reference Guide

Chapter 2: ENVI Routines

197

ENVI_BUFFER_ZONE_DOIT
Use this program to create a buffer-zone image from a classification image. Each
pixel in the output image is the nearest distance, in pixels, from any classified pixel
specified by CLASS_PTR. Any pixels which are farther away from the
MAX_DISTANCE are set to MAX_DISTANCE.

Syntax
ENVI_DOIT, ENVI_BUFFER_ZONE_DOIT

Keywords
CLASS_PTR
Use this keyword to specify the classes around which to compute the buffer zone.
CLASS_PTR is a long array of class numbers ranging from zero (Unclassified) to the
number of classes.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]:Unused for this function, set to -1.

DIMS[1]:The starting X pixel. (The first pixel is number zero.)

DIMS[2]:The ending X pixel.

DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

DIMS[4]:The ending Y pixel.

DISTANCE_DT (optional)
Use this keyword to specify the output data type. DISTANCE_DT is an integer value
set to zero or one indicating either integer or floating point distance, respectively.
Depending on the maximum distance, integer data types are either byte, unsigned
integer, or unsigned long integer. The default is one (floating point output).

ENVI Reference Guide

ENVI_BUFFER_ZONE_DOIT

198

Chapter 2: ENVI Routines

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY (optional)
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

MAX_DISTANCE
Use this keyword to specify the maximum distance for the buffer zone.
MAX_DISTANCE is a long integer in pixels specifying the maximum buffer zone to
compute. Pixels greater than MAX_DISTANCE will be set to MAX_DISTANCE.

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_envi_buffer_zone_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors

ENVI_BUFFER_ZONE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

199

; and warnings to the file batch.txt


;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtm_sam.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the POS and DIMS keywords to
; processes the first band (classifcation
; images only have one band) and all the
; pixels. The MAX_DISTANCE and CLASS_PTR
; keywords are set to create a buffer
; zone of 20 pixels around the second
; class (remember the first class is the
; unclassified class).
;
envi_file_query, fid, ns=ns, nl=nl
pos = [0]
dims = [-1l, 0, ns-1, 0, nl-1]
out_name = testimg
max_distance = 20
distance_dt = 1
class_ptr = [1]
;
; Call the doit
;
envi_doit,envi_buffer_zone_doit, $
fid=fid, pos=pos, dims=dims, $
max_distance=max_distance, class_ptr=class_ptr, $
distance_dt=distance_dt, out_name=out_name
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

ENVI_BUFFER_ZONE_DOIT

200

Chapter 2: ENVI Routines

ENVI_CAL_DOIT
Use this program to spectrally calibrate an image using Flat Field or IARR.

Syntax
ENVI_DOIT, ENVI_CAL_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

DSTR
Use this keyword to specify a named variable that will hold one of the following
descriptions (depending on which method was used to calculate the mean values):
'Flat Field' or 'IARR Calibration'.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

ENVI_CAL_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

201

MEAN
Use this keyword to specify an array of values to divide into each band. MEAN is an
array of floating-point numbers equal in size to the number of bands specified.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_envi_cal_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the

ENVI Reference Guide

ENVI_CAL_DOIT

202

Chapter 2: ENVI Routines


; flat field calibration on all
; samples and all bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
mean = [1.39, 2.15, 3.41, $
1.73, 1.92, 4.32]
dstr = Flat Field
;
; Perform the Flat Field calibration
;
envi_doit, envi_cal_doit, $
fid=fid, pos=pos, dims=dims, $
mean=mean, dstr=dstr, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI_CAL_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

203

ENVI_CENTER
Use this procedure to get the centering offsets for a widget.

Syntax
ENVI_CENTER, Xoff, Yoff

Arguments
XOFF
A named variable that will contain the X (horizontal) offset for use in the call to
WIDGET_BASE.

YOFF
A named variable that will contain the Y (vertical) offset for use in the call to
WIDGET_BASE.

Keywords
XBIG (optional)
Set this optional keyword if the widget will be large in the horizontal direction.

YBIG (optional)
Set this optional keyword if the widget will be large in the vertical direction.

Example
This example gets the centering information from ENVI_CENTER and uses it in the
call to WIDGET_BASE.
envi_center, xoff, yoff
base = widget_base(title=Center test, xoff=xoff, $
yoff=yoff, /column)

ENVI Reference Guide

ENVI_CENTER

204

Chapter 2: ENVI Routines

ENVI_CLOSE_DISPLAY
This routine closes an ENVI display group.

Syntax
ENVI_CLOSE_DISPLAY, DN

Arguments
DN
The display number corresponding to an open display. Display numbers (DNs) are
zero-based; ENVI Display #1 will have DN=0.

Keywords
None

Example
To close the image display group #3, use the following code:
ENVI_CLOSE_DISPLAY, 2

ENVI_CLOSE_DISPLAY

ENVI Reference Guide

Chapter 2: ENVI Routines

205

ENVI_CLOVER_DOIT
Use this program to overlay a classification image on the output image.

Syntax
ENVI_DOIT, ENVI_CLOVER_DOIT

Keywords
CFID
Use this keyword to specify the file ID for the classification image. This is the value
returned from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a
long integer with a value greater than zero. An invalid file ID is specified as -1.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

ENVI Reference Guide

ENVI_CLOVER_DOIT

206

Chapter 2: ENVI Routines

OVERLAY_LUT
Use this keyword to specify an array indicating which classes to overlay on the
image. For example, to overlay classes 2, 3 and 4, set the keyword as follows:
overlay_lut = [2, 3, 4]

Note
Class numbers are zero based and the unclassified class is usually class zero.
If you overlay all the classes on the output image, the output image will not be
visible. Typically, unclassified pixels are not overlain.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_clover_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;

ENVI_CLOVER_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

207

; Open the data and class files


;
envi_open_file, bhtmref.img, r_fid=fid
envi_open_file, bhtm_sam.img, r_fid=cfid
if (fid eq -1 or cfid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the necessary variables
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = [0,1,2]
out_name = testimg
overlay_lut = [1,4,5]
cpos = [0]
;
; Call the doit
;
envi_doit, envi_clover_doit, $
fid=fid, pos=pos, dims=dims, $
cfid=cfid, cpos=cpos, dn=-1, $
overlay_lut=overlay_lut, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

ENVI_CLOVER_DOIT

208

Chapter 2: ENVI Routines

ENVI_COLLECT_SPECTRA
Use this routine to perform spectra collection. Spectra collection is the collection of
spectral signatures directly from ASCII files, spectral libraries, ROIs, statistics files,
or by using the drag-and-drop method. The ENVI_COLLECT_SPECTRA dialog
is not modalized, which allows the user to interact with ENVI and collect spectra
using any of the above techniques. The collected spectra are often used in spectralbased processing such as unmixing or classification.
Note
An interactive ENVI session is required to run this routine.
The collected spectra are provided to the user through the procedure defined by the
keyword PROCEDURE. After at least one spectrum has been collected, selecting the
Apply button will call the defined procedure. The procedure call provides
information supplied by the user (keywords: FID, DIMS, POS, M_FID, M_POS,
INFO) plus information about the collected spectra (spectral data, names, and color).
Note
For more information, see Using Endmember Collection Widgets in Chapter 8 of
the ENVI Programmers Guide.

Syntax
ENVI_COLLECT_SPECTRA

Keywords
DIMS (optional)
Use this optional keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-elements array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

ENVI_COLLECT_SPECTRA

ENVI Reference Guide

Chapter 2: ENVI Routines

209

The default is to use DIMS = [-1, 0, ns - 1, 0, nl - 1], where ns is the number of


samples and nl is the number of lines.

FID
Use this keyword to specify the file ID for the open file. This is the value returned by
the R_FID keyword to the ENVI_OPEN_FILE procedure, or the FID keyword to
ENVI_SELECT. FID is a long integer with a value greater than zero. An invalid file
ID is specified as -1. The value of FID is passed to PROCEDURE with the FID
keyword.

INFO (optional)
Use this optional keyword to specify any user-defined data to pass to the routine
defined by PROCEDURE. The value of INFO can be any IDL variable, including
structures. The value of INFO is passed to PROCEDURE with the INFO keyword.

M_FID (optional)
Use this optional keyword to specify the file ID for the mask file. This is the value
returned from the keyword R_FID in the ENVI_OPEN_FILE procedure, or the FID
keyword to ENVI_SELECT. M_FID is a long integer with a value greater than zero.
An invalid file ID is specified as -1. The value of M_FID is passed to PROCEDURE
with the M_FID keyword.

M_POS (optional)
Use this optional keyword to specify the band position of the mask band. M_POS is a
single long value greater than or equal to zero and less than the number of bands in
the file specified by M_FID. The value of M_POS is passed to PROCEDURE with
the M_POS keyword.

POS (optional)
Use this optional keyword to specify an array of band positions. POS is an array of
long integers that range from zero to (number of bands)-1. The default is
POS = LINDGEN(NB), where the number of bands is retrieved from the file
specified by FID. The value of POS is passed to PROCEDURE with the POS
keyword.

ENVI Reference Guide

ENVI_COLLECT_SPECTRA

210

Chapter 2: ENVI Routines

PROCEDURE
Use this keyword to specify the procedure to call when the Apply button is selected.
PROCEDURE must have the following definition even if you do not specify the
optional keywords to ENVI_COLLECT_SPECTRA:
PRO MY_PROCEDURE, FID=FID, POS=POS, DIMS=DIMS, $
INFO=INFO, M_FID=M_FID, M_POS=M_POS, SPEC=SPEC, $
SNAMES=SNAMES, SCOLORS=SCOLORS, _EXTRA=_EXTRA

Where FID, POS, DIMS, INFO, M_FID and M_POS are passed through from the
call to ENVI_COLLECT_SPECTRA. SPEC, SNAMES and SCOLORS contain
information about the collected spectra. The SPEC array contains the data for the
collected spectra [nb, nspec]; SNAMES is a string array of the collected spectra
names; SCOLOR is an array of graphics color indexes. To convert graphics colors to
RGB triplets, see ENVI_GET_RGB_TRIPLETS. The EXTRA keyword is used to
collect unused keywords.

TITLE (optional)
Use this optional keyword to specify the string used in the title bar of the Spectral
Collection dialog window. Enter the title enclosed in single quotes. The default is
Endmember Collection

Example
pro example_envi_collect_spectra
envi_select, fid=fid
if (fid eq -1) then return
envi_collect_spectra, fid=fid, procedure=my_procedure
end
;
; Define the procedure to called each time the
; apply button is selected.
;
pro my_procedure, fid=fid, pos=pos, dims=dims, spec=spec, $
snames=snames, scolors=scolors, _extra=_extra
print, snames , snames
print, scolors , scolors
print, spec
, spec
end

ENVI_COLLECT_SPECTRA

ENVI Reference Guide

Chapter 2: ENVI Routines

211

ENVI_COMPUTE_SUN_ANGLES
Use this function to compute the Sun elevation and azimuth angles for a given time,
latitude, and longitude. This function returns a two element double array of the Suns
elevation and azimuth for the selected input values.

Syntax
Result = ENVI_COMPUTE_SUN_ANGLES (Day, Month, Year, GMTtime, Lat,
Lon)

Arguments
Day
Use this keyword to specify the day of the year for the desired sun angles. Day is an
integer value between and including 1 to 31.

GMTtime
Use this keyword to specify the GMT time for the desired sun angles. GMTtime is
floating point value between and including 0 to 2400. For example, set GMTtime
equal to 1430. to represent a GMT time of 2:30pm.

Lat
Use this keyword to specify the latitude for the desired sun angles. Lat is a floating
point number in degrees. North is positive and South negative.

Lon
Use this keyword to specify the longitude for the desired sun angles. Lon is a floating
point number in degrees. East is positive and West is negative.

Month
Use this keyword to specify the month of the year for the desired sun angles. Month
is an integer from 1 to 12.

Year
Use this keyword to specify the year for the desired sun angles. Year is a four-digit
integer value of the form yyyy.

ENVI Reference Guide

ENVI_COMPUTE_SUN_ANGLES

212

Chapter 2: ENVI Routines

Example
This example computes the Suns elevation and azimuth angles for N34, W117 July
4, 1984 GMT 10:45pm.
angles
34.,
print,
print,

= envi_compute_sun_angles(4, 7, 1984, 2245., $


-117.)
Sun elevation= , angles[0]
Sun azimuth= , angles[1]

See Also
TOPO_DOIT

ENVI_COMPUTE_SUN_ANGLES

ENVI Reference Guide

Chapter 2: ENVI Routines

213

ENVI_CONVERT_FILE_COORDINATES
Use this procedure to convert between map and pixel coordinates for a particular file.
This utility converts X and Y pixel coordinates into their corresponding X and Y map
coordinates and vice-versa. The FID argument is used to retrieve the appropriate map
projection information.

Syntax
ENVI_CONVERT_FILE_COORDINATES, Fid, XF, YF, XMap, YMap

Arguments
FID
Use this argument to specify a named variable to contain the file ID for the open file.
The file ID is used to get the appropriate projection information for the conversion. If
the file does not have an associated projection, the file coordinates and map
coordinates are equal. FID is the value returned from the keyword R_FID in the
ENVI_OPEN_FILE procedure. An invalid file ID is specified as -1.

XF
If the TO_MAP keyword is set, XF is a variable containing the X file coordinates to
convert. XF can be a single value or an array of values. The first file coordinate is
zero.
If the TO_MAP keyword is not set, XF is a named variable that will contain the
returned X file coordinates for the input XMap and YMap arrays.

YF
If the TO_MAP keyword is set, YF is a variable containing the Y file coordinates to
convert. YF can be a single value or an array of values. The first file coordinate is
zero.
If the TO_MAP keyword is not set, YF is a named variable that will contain the
returned Y file coordinates for the input XMap and YMap arrays.

XMap
If the TO_MAP keyword is set, XMap is a named variable that will contain the
returned X map coordinates for the input XF and YMap arrays.

ENVI Reference Guide

ENVI_CONVERT_FILE_COORDINATES

214

Chapter 2: ENVI Routines

If the TO_MAP keyword is not set, XMap is a variable containing the X map
coordinates to convert. XMap can be a single value or an array of values.

YMap
If the TO_MAP keyword is set, YMap is a named variable that will contain the
returned Y map coordinates for the input XF and YF arrays.
If the TO_MAP keyword is not set, YMap is a variable containing the Y map
coordinates to convert. YMap can be a single value or an array of values.

Keywords
TO_MAP
Set this keyword to convert the input file coordinates to map coordinates.

Example
This example converts the first three pixels on the first line to map coordinates.
xf = [0,1,2]
yf = [0,0,0]
envi_convert_file_coordinates, fid, xf, yf, xmap, ymap, /to_map

See Also
WIDGET_GEO
WIDGET_MAP

ENVI_CONVERT_FILE_COORDINATES

ENVI Reference Guide

Chapter 2: ENVI Routines

215

ENVI_CONVERT_FILE_MAP_PROJECTION
Use this routine to convert a file from its current map projection to the specified
output projection. This routine requires an input file, the output projection, and the
resampling and warping method; no ground control points are needed (they are
generated internally). This routine will convert among any projections in ENVI.
Neither the input or output projection can be Arbitrary.

Syntax
ENVI_CONVERT_FILE_MAP_PROJECTION

Keywords
BACKGROUND (optional)
Use this optional keyword to specify the output image background value. All pixels
outside the warped-image boundary will be set to the value specified by
BACKGROUND. The default is zero.

DEGREE (optional)
Use this optional keyword to specify the degree of the warping polynomial for the
Polynomial method. The degree of the polynomial is limited by the number of GCPs.
You must ensure that #GCPs > (degree + 1)2. The Default is one (first degree).

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

ENVI Reference Guide

ENVI_CONVERT_FILE_MAP_PROJECTION

216

Chapter 2: ENVI Routines

FID
Use this keyword to specify the file ID for the open file. The input file must be
georeferenced in any projection other than Arbitrary. FID is the value returned from
the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer with
a value greater than zero. An invalid file ID is specified as -1.

GCP_NAME (optional)
Use this keyword to specify the output filename for the warp-points filename.
GCP_NAME is a single string specifying an output filename.
If WARP_METHOD is set to 3, this keyword is ignored.

GRID (optional)
Use this keyword to specify the grid spacing in pixels for the X and Y warp points.
GRID is a two-element long array, specifying the X and Y grid spacing (respectively)
in pixels for the warp points used to convert between the two map projections.
Regardless of the GRID value, a minimum of the four corner points will be used. The
default is to use every 10th point in both X and Y.
If WARP_METHOD is set to 3, this keyword is ignored.

O_PIXEL_SIZE (optional)
Use this keyword to specify the X and Y pixel size. O_PIXEL_SIZE is a two-element
double-precision array of the output X and Y pixel sizes, respectively.

O_PROJ
Use this keyword to specify the output projection for the converted file. O_PROJ
cannot be set to the Arbitrary projection. O_PROJ is a projection structure returned
from ENVI_GET_PROJECTION or ENVI_PROJ_CREATE.

OUT_BNAME (optional)
Use this optional keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. OUT_NAME
is a string variable specifying the filename and path of the output file.

ENVI_CONVERT_FILE_MAP_PROJECTION

ENVI Reference Guide

Chapter 2: ENVI Routines

217

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

RESAMPLING (optional)
Set this keyword equal to one of the following values to specify the resampling
method:

0 Nearest Neighbor

1 Bilinear

2 Cubic Convolution

The default is to use Nearest Neighbor, which is method 0.

WARP_METHOD (optional)
Set this optional keyword equal to one of the following values to specify the warp or
rigorous projection method:

0 RST

1 Polynomial

2 Triangulation

3 Rigorous (pixel by pixel)

The default is to use RST, which is method 0.


If WARP_METHOD is set to 3 for Rigorous, the GCP_NAME and GRID keywords
are ignored.

ZERO_EDGE (optional)
Set this optional keyword to specify that the edges outside of any triangles be set to
the value specified by BACKGROUND. The keyword is used only for Triangulation
(method 2).

ENVI Reference Guide

ENVI_CONVERT_FILE_MAP_PROJECTION

218

Chapter 2: ENVI Routines

Example
The following example will convert the file bhtmref.img from UTM zone 13 North
to UTM zone 12 North. This example uses the following files found in the DATA
directory of the ENVI installation:

bhtmref.img

bhtmref.hdr

The output UTM projection is created using ENVI_PROJ_CREATE, with UTM zone
12 North, the default datum of North America 1927, and the default units of Meters.
The output pixel size is set to 28.5 meters for both X and Y. The conversion will use
the RST method with bilinear resampling.
forward_function envi_proj_create
pro envi_convert_file_map_projection
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
; Open the input file
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Setup the values for the keywords
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
pos = lindgen(nb)
dims = [-1l, 0, ns-1, 0, nl-1]
out_name = testimg
o_proj = envi_proj_create(/utm, zone=12)
o_pixel_size = [28.5, 28.5]
;
; Call the doit
;

ENVI_CONVERT_FILE_MAP_PROJECTION

ENVI Reference Guide

Chapter 2: ENVI Routines

219

envi_convert_file_map_projection, fid=fid, $
pos=pos, dims=dims, o_proj=o_proj, $
o_pixel_size=o_pixel_size, grid=[50,50], $
out_name=out_name, warp_method=0, $
resampling=1, background=0
;
; Exit ENVI
;
envi_batch_exit
end

See Also
ENVI_CONVERT_FILE_COORDINATES
ENVI_CONVERT_PROJECTION_COORDINATES
ENVI_GET_PROJECTION
ENVI_PROJ_CREATE

ENVI Reference Guide

ENVI_CONVERT_FILE_MAP_PROJECTION

220

Chapter 2: ENVI Routines

ENVI_CONVERT_LIDAR_DATA_DOIT
The ENVI_CONVERT_LIDAR_DATA_DOIT procedure reads in a LAS standard
formatted LIDAR data file and converts it to either an ENVI image file or an EVF
file.

Syntax
ENVI_DOIT, ENVI_CONVERT_LIDAR_DATA_DOIT
[, BACKGROUND=value] [, DATA_TYPE=integer] [, /EXTRAP],
FNAME=string, /IN_MEMORY | OUT_FNAME=string [, INTERP={0 | 1}]
[, MODEL_TYPE={0 | 1 | 2}] [, OMAP_INFO=variable] [, /OPEN]
[, OUT_IMAGE={1 | 2 | 3}] [, R_FID=variable] [, /VECTOR]

Arguments
None

Keywords
BACKGROUND (optional)
Use this keyword to specify a floating-point value to be used for the elevation and
intensity data that lie outside of the calculated triangles defined by the LAS point
data. The default value for this keyword is 0.

DATA_TYPE (optional)
Set this keyword to specify an integer value that indicates the IDL data type of the
output data. The following table shows the IDL convention used for this keyword.
Value

Data Type

Byte (8-bits)

Integer (16-bits)

Long Integer (32-bits)

ENVI_CONVERT_LIDAR_DATA_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

221

Value

Data Type

Floating-point (32-bits)

Double-precision Floating-point (64-bits)

Complex (2x32-bits)

Double-precision Complex (2x64-bits)

12

Unsigned Integer (16-bits)

13

Unsigned Long Integer (32-bits)

14

Long 64-bit Integer

15

Unsigned Long 64-bit Integer

The default data type is integer (DATA_TYPE = 2).


Note
The DATA_TYPE keyword only applies when converting the LAS LIDAR data to
ENVI raster data. If the VECTOR keyword is set, the DATA_TYPE keyword is
ignored.

EXTRAP (optional)
Set this keyword to extrapolate the results past the bounds of the data.
Note
The EXTRAP keyword only applies when converting the LAS LIDAR data to
ENVI raster data. If the VECTOR keyword is set, the EXTRAP keyword is
ignored.

FNAME
Set this keyword to a string representing the name (including the full path) of the
input LAS LIDAR file.

ENVI Reference Guide

ENVI_CONVERT_LIDAR_DATA_DOIT

222

Chapter 2: ENVI Routines

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

INTERP (optional)
Set this keyword to specify an integer value that indicates the type of interpolation
used to convert the data.
The INTERP keyword can be set to any integer value shown in the following table.
Value

Interpolation Method

Linear (default)

Quintic

Note
The INTERP keyword only applies when converting the LAS LIDAR data to ENVI
raster data. If the VECTOR keyword is set, the INTERP keyword is ignored.

MODEL_TYPE (optional)
Use this keyword to specify an integer value that indicates the type of model used to
convert the data. The MODEL_TYPE keyword can be set to any integer value shown
in the following table.

ENVI_CONVERT_LIDAR_DATA_DOIT

Value

Model Type

Last Return (default)

Full Feature

First Return

ENVI Reference Guide

Chapter 2: ENVI Routines

223

Note
The MODEL_TYPE keyword only applies when converting the LAS LIDAR data
to ENVI raster data. If the VECTOR keyword is set, the MODEL_TYPE keyword
is ignored.

OMAP_INFO (optional)
Use this keyword to specify the output map information structure that the data should
be written to. This structure should have the same format as that returned from
ENVI_MAP_INFO_CREATE.

OPEN (optional)
Set this keyword to automatically open the resulting ENVI image file in the Available
Bands List, or the ENVI vector file in the Available Vectors List.

OUT_FNAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OUT_IMAGE (optional)
Use this keyword to specify an integer value that indicates the type of raster output
produced. The OUT_IMAGE keyword can be set to any integer value shown in the
following table.
Value

Model Type

Elevation Only

Intensity Only

Elevation and Intensity


(default)

Note
The OUT_IMAGE keyword only applies when converting the LAS LIDAR data to
ENVI raster data. If the VECTOR keyword is set, the OUT_IMAGE keyword is
ignored.

ENVI Reference Guide

ENVI_CONVERT_LIDAR_DATA_DOIT

224

Chapter 2: ENVI Routines

R_FID (optional)
Use this optional keyword to specify a named variable to contain the file ID for the
resulting ENVI image file or the vector ID for the resulting vectors. This file ID can
be used to subsequently access the resulting processed data. This keyword returns a
value of 1 if an error occurs trying to create an ENVI raster file, and a null pointer if
an error occurs trying to create an ENVI vector file.

VECTOR (optional)
Set this keyword to save the data as vectors to an ENVI vector file. By default
(VECTOR = 0), the data is converted to raster and saved to an ENVI image file.

ENVI_CONVERT_LIDAR_DATA_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

225

ENVI_CONVERT_PROJECTION_COORDINAT
ES
Use this routine to convert map coordinates from one projection to another. The
routine supports conversion among any ENVI projection types including userdefined. For example, this routine can convert UTM coordinates to Geographic
(Latitude and Longitude) or between UTM zones.

Syntax
ENVI_CONVERT_PROJECTION_COORDINATES, iXmap, iYmap, iProj, oXmap,
oYmap, oProj

Arguments
iProj
Use this argument to specify the input projection for the iXmap and iYmap points.
iProj is a projection structure returned from ENVI_GET_PROJECTION or
ENVI_PROJ_CREATE.

iXmap
Use this argument to specify the input X map points which will be converted from the
iProj projection to the oProj projection. iXmap can be a single value or an array of
values.

iYmap
Use this argument to specify the input Y map points, which will be converted from
the iProj projection to the oProj projection. iYmap can be a single value, or an array
of values.

oProj
Use this argument to specify the output projection for the converted iXmap and
iYmap points. oProj is a projection structure returned from
ENVI_GET_PROJECTION or ENVI_PROJ_CREATE.

ENVI Reference Guide

ENVI_CONVERT_PROJECTION_COORDINATES

226

Chapter 2: ENVI Routines

oXmap
Use this argument to specify a named variable that will contain the converted X map
points. The oXmap points are the input X map coordinates converted to the oProj
projection.

oYmap
Use this argument to specify a named variable that will contain the converted Y map
points. The oYmap points are the input Y map coordinates converted to the oProj
projection.

Keywords
INPUT_Z (optional)
Use this keyword to specify the input elevation values corresponding to each of the
input iXmap and iYmap points. Elevation values are used to more accurately convert
between different data. INPUT_Z is a floating point array having the same length as
iXmap.

OUTPUT_Z (optional)
Use this optional keyword to specify a named variable that will contain the output
elevation values for each of the converted map coordinates. OUTPUT_Z is set only if
INPUT_Z is specified.

Example
This example converts a series of latitude and longitude points in a Geographic
projection to a UTM Zone 11 projection. The new map points are converted to a
UTM zone 12 projection. First, we will create the Geographic and UTM zone 11
projections using ENVI_PROJ_CREATE. Next, we create an array of XY latitude
and longitude map coordinates. These are the points that will be converted to the
UTM zone 11 projection using
ENVI_CONVERT_PROJECTION_COORDINATES. The results of the UTM zone
11 map coordinates will not be converted to UTM zone 12 map coordinates.
;
; Build the projections using
; the standard defaults
;
iproj = ENVI_PROJ_CREATE(/geographic)
oproj = ENVI_PROJ_CREATE(/utm,zone=11)

ENVI_CONVERT_PROJECTION_COORDINATES

ENVI Reference Guide

Chapter 2: ENVI Routines

227

;
; Create the pairs of Latitude and Longitude
ixmap = [-117., -117.5, -118., $
-117., -117.5, -118.]
iymap =
[34.0, 34.0, 34.0, $
35.0, 35.0, 35.0]
;
; Convert from Geographic to UTM zone 11
;
ENVI_CONVERT_PROJECTION_COORDINATES, $
ixmap, iymap, iproj, $
oxmap, oymap, oproj
;
; Convert from UTM zone 11 to UTM zone 12
;
oproj2 = ENVI_PROJ_CREATE (/utm,zone=12)
ENVI_CONVERT_PROJECTION_COORDINATES, $
oxmap, oymap, oproj, $
oxmap2, oymap2, oproj2

See Also
ENVI_GET_PROJECTION
ENVI_MAP_INFO_CREATE
ENVI_PROJ_CREATE

ENVI Reference Guide

ENVI_CONVERT_PROJECTION_COORDINATES

228

Chapter 2: ENVI Routines

ENVI_CREATE_ROI
This function is used to create a new Region of Interest (ROI). ENVI_CREATE_ROI
returns the ROI id of the newly created region. Points are added to the ROI using the
routine ENVI_DEFINE_ROI (see ENVI_DEFINE_ROI on page 244).

Syntax
Result = ENVI_CREATE_ROI()

Keywords
COLOR (optional)
Use this keyword to specify the graphics color index of the ROI. The default graphics
color index is 2.

FILL_MODE (optional)
Use this optional keyword to specify the IDL fill style for polygon ROIs.
FILL_MODE is an integer specifying the IDL fill style. The default value is 1 (solid
fill).

FILL_ORIEN (optional)
Use this optional keyword to specify the rotation of fill for polygon ROIs.
FILL_ORIEN is an integer greater than 1 specifying the fill rotation. This keyword is
only used for FILL_MODE greater than one. The default value is 45

FILL_SPACING (optional)
Use this optional keyword to specify the spacing of fill for polygon ROIs.
FILL_SPACING is floating point number indicating the fill spacing. This keyword is
only used for FILL_MODE greater than one. The default value is 0.1.

NAME (optional)
Use this keyword to specify a string variable for the ROI name. The default for
NAME is New Region.

NL
Use this keyword to specify the ROI spatial-line dimension tied to the ROI.

ENVI_CREATE_ROI

ENVI Reference Guide

Chapter 2: ENVI Routines

229

NO_UPDATE (optional)
Set this optional keyword to indicate the newly created ROI should not appear in the
ROI Tool.

NS
Use this keyword to specify the ROI spatial sample dimension tied to the ROI.

Example
Use ENVI_CREATE_ROI to create a new ROI. Then, add a polygon to the ROI
using ENVI_DEFINE_ROI.
roi_id = envi_create_roi(color=4, name=Test roi, ns=512, nl=512)
xpts = [100, 200, 200, 100, 100]
ypts = [100, 100, 200, 200, 100]
envi_define_roi, roi_id, /polygon, xpts=xpts, ypts=ypts

See Also
ENVI_DEFINE_ROI
ENVI_GET_ROI_DATA
ENVI_GET_ROI_DIMS_PTR
ENVI_GET_ROI_IDS
ENVI_RESTORE_ROIS
ENVI_SAVE_ROIS

ENVI Reference Guide

ENVI_CREATE_ROI

230

Chapter 2: ENVI Routines

ENVI_CUBE_3D_DOIT
Use this program to build a 3D image cube.

Syntax
ENVI_DOIT, ENVI_CUBE_3D_DOIT

Keywords
BORDER
Use this keyword to specify the number of boarder pixels surrounding the image
cube.

CT
Use this keyword to specify the color table used for the spectral-profile colors. CT is
a byte array (256,3).

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

ENVI_CUBE_3D_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

231

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify a one-dimensional array of band positions for the
spectral profile. POS is an array of long integers, ranging from zero to the number of
bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

RGB_POS
Use this keyword to specify the three RGB band positions for the cube face.

SCALE
Use this keyword to specify a spectral scale factor that can be used to exaggerate or
compress the spectral profile. A value greater than 1.0 exaggerates the spectral
profile; a value less than 1.0 compresses the spectral profile. SCALE must be set to
1.0, if the spectral profile is not to be changed.

Example
pro example_envi_cube_3d_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file

ENVI Reference Guide

ENVI_CUBE_3D_DOIT

232

Chapter 2: ENVI Routines


;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords DIMS and POS to
; use all pixles and all bands for the
; spatial and spectral parts of the cube.
; Use band 3,2,1 as the RGB bands for the
; front face of the cube.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1L, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
rgb_pos = [3,2,1]
out_name = testimg
;
; Set the CT keyword to the fifth color
; table from the IDL colors1.tbl file.
;
openr, unit, filepath(colors1.tbl, $
sub=[resource,colors]), $
/block, /get
a = assoc(unit, bytarr(256,3), 1)
ct = a[4]
ct[0,*] = 0
free_lun, unit
;
; Call the doit
;
envi_doit, envi_cube_3d_doit, $
fid=fid, pos=pos, dims=dims, $
out_name=out_name, scale=10.0, $
border=30, rgb_pos=rgb_pos, ct=ct, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI_CUBE_3D_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

233

ENVI_DEFAULT_STRETCH_CREATE
Use this routine to return an ENVI default stretch structure. The default stretch is an
element of the ENVI header and is used to set the default stretch when displaying
data from a file. To set a default stretch, create the default stretch structure using
ENVI_DEFAULT_STRETCH_CREATE and set the DEF_STRETCH keyword to
the ENVI_SETUP_HEAD or ENVI_ENTER_DATA routines. The keywords
LINEAR, PCT_LINEAR, GAUSSIAN, EQUALIZE, SQUARE_ROOT and NONE
define the type of stretch created. The default type is NONE. The VAL1 and VAL2
keywords are used to specify required values for defining the different stretch types.
This routine should be used instead of directly accessing the default stretch structure.

Syntax
Result = ENVI_ DEFAULT_STRETCH_CREATE()

Keywords
EQUALIZE (optional)
Set this optional keyword to specify that an Equalization default stretch structure is
created. The keywords VAL1 and VAL2 are not used with this stretch.

GAUSSIAN (optional)
Set this optional keyword to specify that a Gaussian default stretch structure is
created. Use the keyword VAL1 to specify the number of gaussian standard
deviations for the stretch. The default for VAL1 is 2. The keyword VAL2 is not used
with this stretch.

LINEAR (optional)
Set this optional keyword to specify that a Linear Range default stretch structure is
created. Use the keyword VAL1 to specify the minimum and VAL2 to specify the
maximum values for the linear stretch range. The defaults for VAL1 and VAL2 are 0
and 255, respectively.

NONE (optional)
Set this optional keyword to create default stretch structure with no stretch defined.
This is the default stretch created if no stretch type is specified. The keywords VAL1
and VAL2 are not used with this stretch.
ENVI Reference Guide

ENVI_DEFAULT_STRETCH_CREATE

234

Chapter 2: ENVI Routines

PCT_LINEAR (optional)
Set this optional keyword to specify that a Percent Linear default stretch structure is
created. Use the keyword VAL1 to specify the percentage for the stretch. For
example, for a 2% stretch set VAL1=2. The default for VAL1 is zero, specifying a 0%
stretch.

SQUARE_ROOT (optional)
Set this optional keyword to specify that a Square Root default stretch structure is
created. The keywords VAL1 and VAL2 are not used with this stretch.

VAL1 (optional)
Use this optional keyword to specify one of the following when the indicated
STRETCH_TYPE keyword is set:
Value

Description

EQUALIZE

VAL1 is not used.

GAUSSIAN

VAL1 is a floating-point number specifying the gaussian


standard deviation for the stretch

LINEAR

VAL1 is a floating-point number specifying the minimum


value for the stretch range

NONE

VAL1 is not used.

PCT_LINEAR

VAL1 is a long integer from 0 to 100 (inclusive) specifying


the percentage stretch.

SQUARE_ROOT

VAL1 is not used.


Table 10-1: VAL1 Keyword Values

ENVI_DEFAULT_STRETCH_CREATE

ENVI Reference Guide

Chapter 2: ENVI Routines

235

VAL2 (optional)
Use this optional keyword to specify one of the following when the indicated
STRETCH_TYPE keyword is set:
Value

Definition

EQUALIZE

VAL2 is not used.

GAUSSIAN

VAL2 is not used.

LINEAR

VAL2 is a floating-point number specifying the maximum


value for the stretch range

NONE

VAL2 is not used.

PCT_LINEAR

VAL2 is not used.

SQUARE_ROOT

VAL2 is not used.


Table 10-2: VAL2 Keyword Values

Examples
The following example will create a default stretch structure for a 2% Linear stretch
def_stretch = ENVI_DEFAULT_STRETCH_CREATE(/PCT_LINEAR, VAL1=2)

The next example will create a default stretch structure for a Linear Stretch between
100 and 200.
def_stretch = ENVI_DEFAULT_STRETCH_CREATE(/LINEAR, VAL1=100,
VAL2=200)

See Also
ENVI_ENTER_DATA
ENVI_SETUP_HEAD

ENVI Reference Guide

ENVI_DEFAULT_STRETCH_CREATE

236

Chapter 2: ENVI Routines

ENVI_DEFINE_MENU_BUTTON
The ENVI_DEFINE_MENU_BUTTON procedure enables you to automatically add
buttons to the ENVI menu system from a user-defined routine in a .pro or .sav file
within the save_add directory. The .pro or .sav file must contain a procedure
named <filename>_define_buttons, where <filename> is the name of that
file. For instance, if the file in the save_add directory is named my_process.pro,
a procedure named my_process_define_buttons.pro needs to be in the
my_process.pro file to be able to add buttons to the ENVI menu system. The
<filename>_define_buttons procedure has only one argument and no
keywords, as shown in the following example code:
PRO my_process_define_buttons, buttonInfo
;
; Define Buttons with ENVI_DEFINE_MENU_BUTTON
;
END

The <filename>_define_buttons procedure is used to call the


ENVI_DEFINE_MENU_BUTTON procedure, which enables you to define a new
button. The ENVI_DEFINE_MENU_BUTTON procedure has one argument and an
assortment of keywords, which includes information on where the new button is

ENVI_DEFINE_MENU_BUTTON

ENVI Reference Guide

Chapter 2: ENVI Routines

237

located in the ENVI menu system. The following figure and comments show an
example of button location terminology in the ENVI menu system.

Figure 10-2: Menu Location Example in the ENVI Main Menu


The Basic Tools option is a button containing a pull-down menu. It is also the parent
button of Resize Data (Spatial/Spectral), Subset Data via ROIs, etc. Resize Data
(Spatial/Spectral) is a child button of Basic Tools. Statistics is a sibling button to
Resize Data (Spatial/Spectral), Subset Data via ROIs, etc. Statistics is also a pulldown button and a parent button.

Syntax
ENVI_DEFINE_MENU_BUTTON, ButtonInfo [, /DISPLAY],
EVENT_PRO=string, /MENU | UVALUE=string
[, POSITION=long integer or string] [, REF_INDEX=long integer]
[, REF_UVALUE=variable], REF_VALUE=string [, /SEPARATOR]
[, /SIBLING], VALUE=string

ENVI Reference Guide

ENVI_DEFINE_MENU_BUTTON

238

Chapter 2: ENVI Routines

Arguments
ButtonInfo
A structure containing information about the new button. This argument must be the
same as the argument used for the <filename>_define_buttons procedure.
Warning
The value of the argument is defined by ENVI and should not be modified.

Keywords
DISPLAY (optional)
Set this optional keyword to add the new button to the Display menu bar in the Main
Image window, instead of the ENVI main menu. The new button is placed in the
ENVI main menu by default (DISPLAY = 0).

EVENT_PRO
Use this keyword to specify a string containing the name of the event handling
procedure for the new button. The specified event handling procedure is called when
the new button is selected. If the MENU keyword is set, the EVENT_PRO keyword
is not required.

MENU (optional)
Set this optional keyword to indicate the new button is a pull-down menu (parent
button). You are not required to specify a value for the UVALUE keyword if the
MENU keyword is set. By default, the MENU keyword is not set (MENU = 0).

POSITION (optional)
Use this optional keyword to specify the location of the new button relative to the
reference button, which is specified with the REF_VALUE keyword.
Note
A new button cannot be added after the Exit option in the File pull-down menu of
the ENVI main menu.

ENVI_DEFINE_MENU_BUTTON

ENVI Reference Guide

Chapter 2: ENVI Routines

239

If the new button is a sibling (/SIBLING) to the reference button, then the position
can be set to one of the following values:

before a string value indicating the new button is placed just before the

reference button.

after a string value indicating the new button is placed just after the

reference button.

negative number a long integer indicating the new button is placed a


relative distance (determined by the number specified) before the reference
button. Zero is not a valid number in this case. For example, a value of 1 is
equivalent to a value of before. A value of 2 places the new button before
the reference button and with one sibling between the new and the reference
button.

positive number a long integer indicating the new button is placed a relative
distance (determined by the number specified) after the reference button. Zero
is not a valid number in this case. A value of +1 is equivalent to a value of
after. A value of +2 places the new button after the reference button and
with one sibling between the new and the reference button.

If the new button is a child of the reference button (SIBLING = 0, its default setting),
then the POSITION keyword can be set to one of the following values:

first a string value indicating the new button is placed as the first

child.

last a string value indicating the new button is placed as the last child.

negative one, zero, or a positive number a long integer indicating the index
(determined by the number specified) of the child button relative to it parent.
For example, a value of zero (POSITION = 0) represents the first child, a value
of one (POSITION = 1) represents the second child, and so forth. A value of
negative one (POSITION = 1) is equivalent to last, which places the new
button as the last child (no matter how many children already exist).

The default value for the POSITION keyword is after (POSITION = after)
for a sibling button and last (POSITION = last) for a child button.

REF_INDEX (optional)
Use this optional keyword to indicate the index of the button used as a reference if the
name specified for the REF_VALUE keyword is not unique. For example, the
Preprocessing option appears in two places in the ENVI menu system, in the Basic
Tools and the Spectral pull-down menus. The index value is based on the sequential
order of the button names in the envi.men file. An index of zero (REF_INDEX = 0)
ENVI Reference Guide

ENVI_DEFINE_MENU_BUTTON

240

Chapter 2: ENVI Routines

represents the first instance in the file, an index of one (REF_INDEX = 1) represents
the second instance, and so forth. If the value specified for REF_INDEX is greater
than the number of instances in the file, the first instance of the button is used as the
reference button. The default value for the REF_INDEX keyword is zero
(REF_INDEX = 0).

REF_UVALUE (optional)
Use this optional keyword to specify a reference button by its user-defined value.
Note
Specifying an existing ENVI button name with the REF_VALUE keyword may not
always produce a match because you can edit the envi.men file and it may have
been changed for a given installation (for example, when translating the button
names into a different language). However, a user-defined value for this button does
not change. The REF_UVALUE keyword enables you to specify this user-defined
value so it can be used as a backup for the REF_VALUE when it does not match
any existing buttons. However, the REF_UVALUE keyword does not work for pulldown menus (parent buttons) because these menus do not produce events.

REF_VALUE
Use this keyword to specify a string containing the name of the reference button,
which is already located in the ENVI menu system.

SEPARATOR (optional)
Set this optional keyword to place a separator before the new button. By default, the
SEPARATOR keyword is not set (SEPARATOR = 0). To place the separator after the
new button, set the SEPARATOR keyword to 1 (SEPARATOR = 1).

SIBLING (optional)
Set this optional keyword to indicate the new button is a sibling of the reference
button, which is specified with the REF_VALUE keyword. By default, a new button
is a child of the reference button unless the SIBLING keyword is set. However, if the
reference button is not a pull-down menu (parent button), you do not need set this
keyword because the new button is always a sibling to that reference button.

UVALUE
Use this keyword to specify a user-defined string containing any useful information
you may want to maintain about the new button. This string is passed to the event

ENVI_DEFINE_MENU_BUTTON

ENVI Reference Guide

Chapter 2: ENVI Routines

241

handling procedure for the new button. If the MENU keyword is set, you are not
required to specify a value for the UVALUE keyword.
Note
In general, the user-defined value of a widget can be of any type, but for this
procedure, the value for the UVALUE keyword must be a string.

VALUE
Use this keyword to specify a string containing the name of the new button you want
to create. The name specified for the VALUE keyword is also used as the label for the
new button.

Examples
The following examples are for a fictitious file named my_process.pro.

Example 1
The first example adds four new buttons. The My Menu pull-down menu (parent
button) is placed in the top level of the ENVI menu system just after the Basic Tools
pull-down menu and just before the Classification pull-down menu. This new My
Menu menu contains three children (Option 1, Option 2, and Option 3).
PRO my_process_define_buttons, buttonInfo
;
;
Basic Tools ->
;
My Menu ->
;
Option 1
;
Option 2
;
-------;
Option 3
;
Classification ->
;
ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = My Menu, $
/MENU, REF_VALUE = Basic Tools, /SIBLING, POSITION = after
ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = Option 1, $
UVALUE = option 1, EVENT_PRO = my_process_event, $
REF_VALUE = My Menu, POSITION = last
ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = Option 2, $
UVALUE = option 2, EVENT_PRO = my_process_event, $
REF_VALUE = My Menu, POSITION = last

ENVI Reference Guide

ENVI_DEFINE_MENU_BUTTON

242

Chapter 2: ENVI Routines


ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = Option 3, $
UVALUE = option 3, EVENT_PRO = my_process_event, $
REF_VALUE = My Menu, POSITION = last, /SEPARATOR
END

Example 2
The previous example used string values for the POSITION keyword. This example
creates the same buttons, but uses integer values for the POSITION keyword.
PRO my_process_define_buttons, buttonInfo
ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = My Menu, $
/MENU, REF_VALUE = File, /SIBLING, POSITION = 2
ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = Option 2, $
UVALUE = option 2, EVENT_PRO = my_process_event, $
REF_VALUE = My Menu, POSITION = 0
ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = Option 1, $
UVALUE = option 1, EVENT_PRO = my_process_event, $
REF_VALUE = Option 2, REF_UVALUE = option 1, POSITION = -1
ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = Option 3, $
UVALUE = option 3, EVENT_PRO = my_process_event, $
REF_VALUE = Option 2, REF_UVALUE = option 1, POSITION = 1, $
/SEPARATOR
END

Example 3
The following example shows how to add some new buttons as children to the
Preprocessing pull-down menus in both the Basic Tools and Spectral menus.
PRO my_process_define_buttons, buttonInfo
ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = New Tools, $
/MENU, REF_VALUE = Preprocessing, REF_INDEX = 0, $
POSITION = last
ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = Tool 1, $
UVALUE = tool 1, EVENT_PRO = my_process_event, $
REF_VALUE = New Tools, POSITION = -1
ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = Tool 2, $
UVALUE = tool 2, EVENT_PRO = my_process_event, $
REF_VALUE = New Tools, POSITION = -1
;
ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = New Tools, $
/MENU, REF_VALUE = Preprocessing, REF_INDEX = 1, $
POSITION = last

ENVI_DEFINE_MENU_BUTTON

ENVI Reference Guide

Chapter 2: ENVI Routines

243

ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = Tool 1, $


UVALUE = tool 1, EVENT_PRO = my_process_event, $
REF_VALUE = New Tools, REF_INDEX = 1, POSITION = -1
ENVI_DEFINE_MENU_BUTTON, buttonInfo, VALUE = Tool 2, $
UVALUE = tool 2, EVENT_PRO = my_process_event, $
REF_VALUE = New Tools, REF_INDEX = 1, POSITION = -1
END

ENVI Reference Guide

ENVI_DEFINE_MENU_BUTTON

244

Chapter 2: ENVI Routines

ENVI_DEFINE_ROI
Use this procedure to define objects in a Region of Interest (ROI). An ROI is defined
by point, polyline, and polygon objects. Each ROI can be composed of multiple
and/or mixed objects. For example, a single ROI may have 100 individual points and
three polygons. Using a ROI_ID returned from ENVI_CREATE_ROI, each call to
ENVI_DEFINE_ROI will add one object to the ROI definition (multiple points may
be added with a single call). Once an ROI is created, it can be used in processing
routines, or saved to an ROI file.

Syntax
ENVI_DEFINE_ROI, Roi_id

Arguments
ROI_id
ROI_Id is a single ID returned from the function ENVI_CREATE_ROI or
ENVI_GET_ROI_IDS.

Keywords
NO_UPDATE (optional)
Set this optional keyword to indicate the ROI Tool is not updated when the ROI is
defined.

POINT (optional)
Set this optional keyword to indicate that the X and Y arrays define a set of points.
When POINT is set, POLYLINE and POLYGON cannot be set.

POLYLINE (optional)
Set this optional keyword to indicate that the X and Y arrays define a polyline. A
polyline is a series of XY points that are connected with a straight line. Only one
polyline can be defined with each call to ENVI_DEFINE_ROI. When POLYLINE is
set, POINT and POLYGON cannot be set.

ENVI_DEFINE_ROI

ENVI Reference Guide

Chapter 2: ENVI Routines

245

POLYGON (optional)
Set this optional keyword to indicate that the X and Y arrays define a polygon. A
polygon is a closed area that is defined by a series of XY points connected together.
In order to properly close the polygon, the first and last point in XPTS and YPTS
must be the same. When POLYGON is set, POINT and POLYLINE cannot be set.

XPTS
Use this keyword to specify an array of X points of the specified type. XPTS is in file
coordinates. One of the keywords, POINT, POLYLINE, or POLYGON, must be set
to indicate the type of XPTS.

YPTS
Use this keyword to specify an array of Y points of the specified type. YPTS is in file
coordinates. One of the keywords, POINT, POLYLINE, or POLYGON, must be set
to indicate the type of YPTS.

Example
This example will create a square polygon ROI that can be displayed onto the
bhtmref.img image. This example uses the following files found in the DATA
directory of the ENVI installation:

bhtmref.img

bhtmref.hdr

First, start ENVI and open the file bhtmref.img. Once the file is open, issue the
ENVI_SELECT command and select the file bhtmref.img. Next, use
ENVI_CREATE_ROI and the returned FID to create an ROI that has the file
attributes associated with bhtmref.img. Now, define the square polygon points and
add this object to the ROI using ENVI_DEFINE_ROI. The resulting ROI can be
overlaid onto a displayed image from bmtmref.img.
;
; Choose the bhtmref.img file
;
ENVI_SELECT, fid=fid
;
; Get the samples and lines for this
; file and create an ROI
;
ENVI_FILE_QUERY, fid, ns=ns, nl=nl
roi_id = ENVI_CREATE_ROI(ns=ns, nl=nl, $

ENVI Reference Guide

ENVI_DEFINE_ROI

246

Chapter 2: ENVI Routines


color=4, name=Square)
;
; Define the square and add
; the polygon object to the ROI
;
xpts = [100, 200, 200, 100, 100]
ypts = [100, 100, 200, 200, 100]
ENVI_DEFINE_ROI, roi_id, /polygon, $
xpts=xpts, ypts=ypts

See Also
ENVI_CREATE_ROI
ENVI_GET_ROI_DATA
ENVI_GET_ROI_DIMS_PTR
ENVI_GET_ROI_IDS
ENVI_RESTORE_ROIS
ENVI_SAVE_ROIS

ENVI_DEFINE_ROI

ENVI Reference Guide

Chapter 2: ENVI Routines

247

ENVI_DELETE_ROIS
Use this program to delete ROIs from within ENVI. The program accepts a list of
ROIs to delete, or optionally deletes all ROIs.

Syntax
ENVI_DELETE_ROIS [, ROI_ids]

Arguments
ROI_ids (optional)
The ROI IDs to delete. This is the value returned from ENVI_GET_ROI_IDS or
ENVI_CREATE_ROI. You may optionally use the keyword ALL to remove all of the
ROIs, instead of specifying the ROI IDs.

Keywords
ALL (optional)
Set this keyword to specify that all ROIs are deleted. If the ALL keyword is set, the
ROI_ids parameter is not used.

Example
roi_ids = envi_get_roi_ids()
envi_delete_rois, roi_ids

ENVI Reference Guide

ENVI_DELETE_ROIS

248

Chapter 2: ENVI Routines

ENVI_DISP_QUERY
This procedure gets display information from the display being queried.
Note
An interactive ENVI session is required to run this routine.

Syntax
ENVI_DISP_QUERY, DN

Arguments
DN
The display number corresponding to an open display. ENVI Display #1 will have
DN=0, Display #2 will have DN=1, etc.

Keywords
COLOR
Use this keyword to specify a named variable that will contain the display color
information. The valid values for COLOR are

0 grayscale image

2 classification image

8 3 band image

FID
Use this keyword to specify a named variable that will contain the file ID for the open
file. This is the value returned from the keyword R_FID in the ENVI_OPEN_FILE
procedure. FID is a long array of size three. For grayscale and classification images,
only the first array element is valid. For RGB displays, each FID element relates to
the red (0), green (1), and blue (2) bands. An invalid file ID is specified as -1.

NL
Use this keyword to specify a named variable that will contain the number of lines in
the file.

ENVI_DISP_QUERY

ENVI Reference Guide

Chapter 2: ENVI Routines

249

NS
Use this keyword to specify a named variable that will contain the number of samples
in the file.

POS
Use this keyword to specify a named variable that will contain the band positions of
the display data. POS is a long array of size three. For grayscale and classification
images only the first array element is valid. For RGB displays, each POS array
element relates to the red (0), green (1), and blue (2) bands.

REBIN (optional)
Use this optional keyword to specify a named variable that will contain the resize
factor currently being used in the Scroll window. If DN is a valid ENVI display
number, the resulting variable (resize in this case) will be a floating-point number.
If the image display doesn't have a Scroll window (i.e., the entire image fits into the
full resolution Image window), but the REBIN keyword is used, a (meaningless)
REBIN value will still be returned.

W1 (optional)
Use this optional keyword to specify a named variable that will contain the window
IDs for the Image, Zoom, and Scroll windows. If DN is a valid ENVI display number,
the resulting variable ("win" in this case) will be a three-element long integer array:

WIN[0]: The IDL window ID of the Image window.

WIN[1]: The IDL window ID of the Zoom window.

WIN[2]: The IDL window ID of the Scroll window.

Note
If there is no scroll window in the specified ENVI display, WIN[2] may be equal to
0 or -1, or it may contain the window ID of an invalid display.

X0 (optional)
Use this optional keyword to specify the x position of the upper left-hand pixel of the
Image window in file coordinates (i.e., zero-based numbers).

ENVI Reference Guide

ENVI_DISP_QUERY

250

Chapter 2: ENVI Routines

XDS
Use this keyword to specify a named variable that will contain the x display size in
pixels for the display windows. XDS is a three-element long array corresponding to
the image, zoom, and scroll windows, respectively.

Y0 (optional)
Use this optional keyword to specify the y position of the upper left-hand pixel of the
Image window in file coordinates (i.e., zero-based numbers).

YDS
Use this keyword to specify a named variable that will contain the y display size in
pixels for the display windows. YDS is a three-element long array corresponding to
the image, zoom, and scroll windows respectively.

ZFACT (optional)
Use this optional keyword to specify a named variable that will contain the zoom
factor currently being used in the Zoom window. If DN is a valid ENVI display
number, the resulting variable (zoom in this case) will be a two element integer
array:

ZOOM[0]: The zoom factor for the full resolution Image window, which will
always be 1.

ZOOM[1] : The current zoom factor for the Zoom window.

Example
envi_disp_query, dn, xds=xds, yds=yds, fid=fid, $
color=color

See Also
ENVI_FILE_QUERY

ENVI_DISP_QUERY

ENVI Reference Guide

Chapter 2: ENVI Routines

251

ENVI_DISPLAY_BANDS
Use this routine to display a grayscale or RGB image in a display window. The image
will be displayed in the current display. Optionally, a new display window may be
created.
Note
An interactive ENVI session is required to run this routine.

Syntax
ENVI_DISPLAY_BANDS, Fid, Pos

Arguments
Fid
A one or three element long integer array of file IDs indicating the file for each of the
grayscale or RGB bands to display. When Fid is a three-element array, the bands
represent the red, green, and blue channels, respectively. All of the files listed in the
Fid array must have the same number of samples and lines.

Pos
A one or three element long integer array of band positions. Elements of Pos are
paired with the elements of the Fid array.

Keywords
NEW (optional)
Set this keyword to specify the creation of a new display window. The default is to
use the current display window. If non exists, an new window is created.

IMAGE_OFFSET (optional)
Use this keyword to specify the X and Y offset of the image window.
IMAGE_OFFSET is a two-element long array specifying the X and Y offset in
screen pixels, respectively.

ENVI Reference Guide

ENVI_DISPLAY_BANDS

252

Chapter 2: ENVI Routines

IMAGE_SIZE (optional)
Use this keyword to specify the X and Y size of the image window. IMAGE_SIZE is
a two element long array specifying the X and Y image size in screen pixels,
respectively.

SCROLL_REBIN (optional)
Use this keyword to specify the initial resize factor for the scroll window.
SCROLL_REBIN is a floating-point number greater than one. The size of the scroll
window is determined using the size of the input image and SCROLL_REBIN. The
size of the scroll window will be (number of samples / SCROLL_REBIN) for X and
(number of lines / SCROLL_REBIN) for Y.

SCROLL_OFFSET (optional)
Use this keyword to specify the X and Y offset of the scroll window.
SCROLL_OFFSET is a two-element long array specifying the X and Y offset in
screen pixels, respectively.

SCROLL_HIDE (optional)
Set this keyword to specify that the scroll window be initially hidden.

WINDOW_STYLE (optional)
Use this optional keyword to specify the window style configuration for new
windows created when the NEW keyword is set. Set WINDOW_STYLE equal to one
of the following values:

0 Image/Scroll/Zoom

1 Scroll/Zoom

2 Image

3 Zoom

The default is to use the window style specified in the Preferences.

ZOOM_FACTOR (optional)
Use this keyword to specify the initial zoom factor for the zoom window.

ZOOM_HIDE (optional)
Set this keyword to specify that the zoom window be initially hidden.

ENVI_DISPLAY_BANDS

ENVI Reference Guide

Chapter 2: ENVI Routines

253

ZOOM_OFFSET (optional)
Use this keyword to specify the X and Y offset of the zoom window.
ZOOM_OFFSET is a two-element long array specifying the X and Y offset in screen
pixels, respectively.

ZOOM_SIZE (optional)
Use this keyword to specify the X and Y size of the zoom window. ZOOM_SIZE is a
two-element long array specifying the X and Y zoom size in screen pixels,
respectively.

Example
The following example displays the first three bands of a file, specified by FID, as an
RGB combination, in a new display window.
envi_display_bands, [fid,fid,fid], [0,1,2], /new

See Also
ENVI_DISP_QUERY

ENVI Reference Guide

ENVI_DISPLAY_BANDS

254

Chapter 2: ENVI Routines

ENVI_DOIT
The ENVI_DOIT routine is the interface for all of the ENVI processing routines (the
_DOIT routines). Each _DOIT is a string argument to ENVI_DOIT with the specific
keywords following the _DOIT argument. For example, the call to CLASS_DOIT is
ENVI_DOIT, CLASS_DOIT, . [CLASS_DOIT keywords].

Syntax
ENVI_DOIT, Routine_Name

Arguments
Routine_Name
Routine_Name is a string variable specifying the processing routine to execute. ENVI
commonly refers to the processing routines as the doit. Many of the internal ENVI
processing routines are available to the programmer in batch mode. The value of
Routine_Name should be any valid _DOIT routine in ENVI. Keywords specific to
Routine_Name can be found under the description for the specific routine.

Keywords
NO_CATCH (optional)
Set this optional keyword to disable the ENVI catch mechanism. The ENVI catch
provides a generalized mechanism for handling exceptions and errors. By disabling
the ENVI catch mechanism, the user then has the option to add their own catch
mechanism. If no catch mechanism is used and an error occurs, ENVI will let the
program stop execution, print an error message, and revert control to the command
line. The ENVI session (interactive or batch) must be continued manually from the
command line. See the CATCH routine to add a user-defined catch mechanism. This
keyword is used only with the routine ENVI_DOIT.

NO_REALIZE (optional)
Set this optional keyword to prevent the Available Bands List from being displayed if
a new output file is created at the end of the Routine_Name process.
Note
If the Available Bands List is already realized, this keyword has no effect.

ENVI_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

255

Note
Some processing routines (such as ENVI_STATS_DOIT) produce dialogs, but do
not produce output files. The NO_REALIZE keyword only applies to cases
resulting in an output file; otherwise, this keyword is ignored.

Routine_Name Keywords
Keywords specific to Routine_Name are found under the description for the routine.

Example
The following example will run statistics on bhtmref.img. This example uses the
following files found in the data directory of the ENVI installation:

bhtmref.img

bhtmref.hdr

First, ENVI is initialized in batch mode and the batch log file is set to batch.txt.
Next, the file bmtmref.img is opened and ENVI_STATS_DOIT is used to perform
basic statistical calculations. The routine ENVI_STATS_DOIT is the string argument
to ENVI_DOIT. The keywords to ENVI_STATS_DOIT are listed in the call to
ENVI_DOIT. After the statistics are completed, the mean value is printed.
pro example_envi_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Get the samples, lines and # bands
; for the input file.

ENVI Reference Guide

ENVI_DOIT

256

Chapter 2: ENVI Routines


;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
;
; Set the dims and pos to calculate
; statistics for all data (spatially and
; spectrally) in the file.
;
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
;
; Calculate the basic statistics and the
; histogram for the input data file. Print
; out the calculated information.
;
envi_doit, envi_stats_doit, fid=fid, pos=pos, $
dims=dims, comp_flag=1, mean=mean
;
print, Mean , mean
;
; Exit ENVI
;
envi_batch_exit
end

See Also
ENVI
ENVI_BATCH_EXIT
ENVI_BATCH_INIT

ENVI_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

257

ENVI_ENTER_DATA
This procedure is used to enter image data in memory into ENVI. The individual
images appear as bands in the Available Bands List and are available for display or
use by other ENVI functions. ENVI_ENTER_DATA internally calls
ENVI_SETUP_HEAD and registers the bands in the available bands list. Items
entered using ENVI_ENTER_DATA are considered IN_MEMORY items.

Syntax
ENVI_ENTER_DATA, Data

Arguments
Data
A two or three-dimensional data array to enter of type Byte, Integer, Unsigned
Integer, Long Integer, Unsigned Long Integer, Long 64 Integer, Unsigned Long 64
Integer, Floating Point, Double Precision, Complex, or Double Complex. The data
must be in BSQ format and have the dimensions Data[samples,lines] or
Data[samples,lines,bands].
Note
The Data array is incorporated into the ENVI session directlyrendering the
variable undefined after the call to ENVI_ENTER_DATA. If you wish to use the
Data array after the call to ENVI_ENTER_DATA, first make a copy and then set
the Data argument equal to the copy.

Keywords
BBL (optional)
Use this optional keyword to specify an array of ones and zeros representing the good
and bad bands. The number of elements in BBL must be equal to the number of bands
in the image. A one represents a good band and a zero represents a bad band.

BNAMES (optional)
Use this optional keyword to specify the band names assigned to the data. BNAMES
is a string array of number-of-bands band names. The default band names are [band
1, band 2], etc.
ENVI Reference Guide

ENVI_ENTER_DATA

258

Chapter 2: ENVI Routines

CLASS_NAMES (optional)
Use this keyword to specify a string array of class names for classification images.
The first element (class 0) is the Unclassified class. CLASS_NAMES must be set
when entering classification images.

DATA_GAINS (optional)
Use this optional keyword to specify a named variable to contain an array of gains for
each band in the data set. DATA_GAINS is an array of values, one for each band.
DATA_GAINS can be used in conjunction with DATA_OFFSETS in ENVI's general
purpose utility Apply Gain and Offset.

DATA_IGNORE_VALUE (optional)
Use this optional keyword to specify a named variable to contain a scalar number
representing the data value to ignore in the data set. If set DATA_IGNORE_VALUE
is the same type as the input data set and an undefined ignore value is represented by
the double precision number 1e-34. Currently, this value is used only in user-written
ENVI code.

DATA_OFFSET (optional)
Use this optional keyword to specify a named variable to contain an array of offsets
for each band in the data set. DATA_OFFSETS is an array of values, one for each
band. DATA_OFFSETS can be used in conjunction with DATA_GAINS in ENVI's
general purpose utility Apply Gain and Offset.

DEF_STRETCH (optional)
Use this optional keyword to specify the default stretch information. Set
DEF_STRETCH equal to the value returned from
ENVI_DEFAULT_STRETCH_CREATE.

DESCRIP (optional)
Use this optional keyword to specify a text description of the data, or of the type of
processing performed.

FILE_TYPE (optional)
Use this optional keyword to specify an integer value indicating the file type. See
ENVI_FILE_TYPE on page 301 for details on how to determine the integer value
of a file type.

ENVI_ENTER_DATA

ENVI Reference Guide

Chapter 2: ENVI Routines

259

FUNC_COMPLEX (optional)
Set this optional keyword to the Complex Lookup Function to determine how to
display complex data. This keyword should be set to one of the following:
0

Power

The natural log of the magnitude, ln(magnitude).


(Default)

Magnitude

Real

The real portion of the complex number.

Imaginary

The imaginary part of the complex number.

Phase

imag inary
arc tan -------------------------real

( real ) + ( imag inary )

Note
Only set this keyword if the IDL data type of the image is 6 = complex (2 x 32-bit)
or 9 = double-precision complex (2 x 64-bit).

FWHM (optional)
Use this optional keyword to specify a floating point array of full-width-halfmaximum responses for each band. The number of elements in this array is equal to
the number of bands in the image.

GEO_POINTS (optional)
Use this optional keyword to specify a 16-element double array of geographic
coordinates for the four corners. The array is comprised of four groups of X and Y
pixel locations and the corresponding latitude and longitude values (negative for
South latitude and negative for West longitude). The four groups of points represent
the four corners: upper left, upper right, lower left, lower right. The array is defined
as follows:
GEO_POINTS[0:3] -> [Y, LAT, LON] - upper left
GEO_POINTS[4:7] -> [X , Y, LAT, LON] - upper right
GEO_POINTS[8:11] -> [X , Y, LAT, LON] - lower left
GEO_POINTS[12:15] -> [X , Y, LAT, LON] - lower right

INFO (optional)
Use this optional keyword to specify user-defined information. INFO is used to store
information which can be passed to users spatial and spectral readers. INFO is
retrieved from ENVI_FILE_QUERY, using the keyword H_INFO, which is a handle

ENVI Reference Guide

ENVI_ENTER_DATA

260

Chapter 2: ENVI Routines

to the data. Use HANDLE_VALUE and the handle H_INFO to retrieve the data
INFO.

INHERIT (optional)
Use this optional keyword to specify the file inheritance. Set INHERIT equal to the
value returned from ENVI_SET_INHERITANCE.

LOOKUP (optional)
Use this keyword to specify a long array of class RGB values for classification
images. The LOOKUP array contains one RGB triple for each class specified with
the NUM_CLASSES keyword. The dimensions of the array are [3,NUM_CLASSES]
and the RGB triplet is ordered [R,G,B]. LOOKUP must be set when entering a
classification image.

MAP_INFO (optional)
Use this optional keyword to specify map information. Set MAP_INFO equal to the
value returned from ENVI_MAP_INFO_CREATE.

NUM_CLASSES (optional)
Use this optional keyword to specify the number of classes for classification images.
Remember to include the Unclassified class (class 0) in the number of classes.
NUM_CLASSES only needs to be set when entering a classification image.

PIXEL_SIZE (optional)
Use this optional keyword to specify the pixel size of images that are not
georeferenced. PIXEL_SIZE is a two-element floating-point array specifying the X
and Y pixel sizes, respectively.

R_FID (optional)
Use this optional keyword to specify a named variable that will contain the file ID of
the entered data.

REFLECTANCE_SCALE_FACTOR (optional)
Use this optional keyword to specify a named variable to contain a single scalar
number used to convert the input data into reflectance. For example,
REFLECTANCE_SCALE_FACTOR would be used to convert integer scaled
reflectance data into their floating point [0,1] reflectance values.

ENVI_ENTER_DATA

ENVI Reference Guide

Chapter 2: ENVI Routines

261

SENSOR_TYPE (optional)
Use this optional keyword to specify an integer value indicating the sensor type. See
ENVI_SENSOR_TYPE on page 452 for details on how to determine the integer
value of a sensor type.

SPEC_NAMES (optional)
Use this optional keyword to specify a string array of spectral library names.
SPEC_NAMES only needs to be set when entering spectral library files.

UNITS (optional)
Use this optional keyword to specify the PIXEL_SIZE units for images that are not
georeferenced. UNITS is an integer value returned from
ENVI_TRANSLATE_PROJECTION_UNITS. Georeferenced images do not use this
value. Instead, they use the pixel size and units contained in the map information
structure.

WAVELENGTH_UNIT (optional)
Use this optional keyword to specify a named variable to contain a value indicating
the wavelength units. The valid values are one of the following:

0 Micrometers

1 Nanometers

2 Wavenumber

3 GHz

4 MHz

5 Index

6 Unknown

WL (optional)
Use this optional keyword to specify an array of wavelength values. The number of
elements in this array is equal to the number of bands.

XSTART (optional)
Use this optional keyword to specify the X starting sample for the first pixel in the
file. The default is zero. XSTART in conjunction with YSTART are used to preserve
the spatial reference for subsetted files. When processing a file, the XSTART of the
ENVI Reference Guide

ENVI_ENTER_DATA

262

Chapter 2: ENVI Routines

output file is typically set to the XSTART of the input file plus the value of DIMS[1]
(the starting sample).

YSTART (optional)
Use this optional keyword to specify the Y starting line for the first pixel in the file.
The default is zero. YSTART in conjunction with XSTART are used to preserve the
spatial reference for subsetted files. When processing a file, the YSTART of the
output file is typically set to the YSTART of the input file plus the value of DIMS[3]
(the starting line).

ZPLOT_AVERAGE (optional)
Use this optional keyword to specify a two-element long array for the X and Y
window size (in pixels) for the Z-Profile. The window size must be 1 or greater.
The Z-Profile is formed from the average of the profiles within the specified window.
The default window size is [1,1].

ZRANGE (optional)
Use this optional keyword to specify a two-dimensional array for the lower and upper
range to be used by default in spectral plots.

ZPLOT_TITLES (optional)
Use this optional keyword to specify a two-element string array for the X and Y plot
titles. The default X title is Band Number for images with no wavelength
information and Wavelength for images with wavelength information. The default
Y axis title is Value.

Examples
The following example will generate 256x256 byte ramp using the function
BINDGEN. This array will then be entered into ENVI using the
ENVI_ENTER_DATA routine. This is the simplest use of ENVI_ENTER_DATA.
data = BINDGEN(256,256)
ENVI_ENTER_DATA, data

The following example will create two classes (plus the Unclassified class) from the
ramp image and enter the resulting classification image into ENVI. The Unclassified
class will be Black [0,0,0], the first class will be Red [255,0,0] and the second class
will be Yellow [255,255,0]. The class names will be Unclassified, Red, and Yellow.

ENVI_ENTER_DATA

ENVI Reference Guide

Chapter 2: ENVI Routines

263

The classification image will have the description Example Classification Image
and the band name Ramp Classification.
;
; Create a 2D ramp and then classify all values
; from 20 to 100 in the first class (classification
; data value equal to one) and classify all values
; from 101 to 220 into the second class
; (classification data value equal to two)
;
data = BINDGEN(256,256)
class = BYTE((data ge 20 and data le 100) + $
2B * (data ge 101 and data le 220))
;
; Create the classification information
;
class_names = [Unclassified,Red,Yellow]
lookup = [[0,0,0],[255,0,0],[255,255,0]]
bnames = [Ramp Classification]
descrip = Example Classification Image
file_type = ENVI_FILE_TYPE(ENVI Classification)
;
; Enter the data into ENVI
;
ENVI_ENTER_DATA, class, num_classes=3, $
class_names=class_names, lookup=lookup, $
file_type=file_type, bnames=bnames, $
descrip=descrip

The following example will take the ramp image and assign a geographic projection
to the image with the upper left corner at 15 degrees south, 48 degrees west, and an X
and Y pixel size of one arc second. The map projection will be created using
ENVI_MAP_INFO_CREATE and the resulting structure will use the MAP_INFO
keyword when entering the data into ENVI.
;
; First create the ramp image. The ramp image
; would actually be replaced by a real
; georeferenced image.
;
data = BINDGEN(256,256)
;
; Create the item used for the projection
;
mc = [.5D,.5, -48,-15]
ps = [1D/3600, 1D/3600]
units = ENVI_TRANSLATE_PROJECTION_UNITS(Degrees)
map_info = ENVI_MAP_INFO_CREATE(/geographic, $
mc=mc, ps=ps, units=units)

ENVI Reference Guide

ENVI_ENTER_DATA

264

Chapter 2: ENVI Routines


;
; Enter the data into ENVI
;
ENVI_ENTER_DATA, data, map_info=map_info

See Also
ENVI_SETUP_HEAD

ENVI_ENTER_DATA

ENVI Reference Guide

Chapter 2: ENVI Routines

265

ENVI_ENVISAT_GEOREF_DOIT
The ENVI_ENVISAT_GEOREF_DOIT procedure georeferences AATSR, ASAR,
and MERIS format ENVISAT data. This procedure extracts geolocation tie points
from header information in the ENVISAT file and uses these tie points to georegister
the ENVISAT data.

Syntax
ENVI_DOIT, ENVI_ENVISAT_GEOREF_DOIT [, BACKGROUND=value]
[, DEGREE=value] [, DIMS=array], F_FID=fileID [, GCP_NAME=string],
/IN_MEMORY | OUT_NAME=string [, OUT_BNAME=string array]
[, OUT_PROJ=structure] [, POS=array] [, R_FID=variable]
[, WARP_METHOD={0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}] [, /ZERO_EDGE]

Arguments
None

Keywords
BACKGROUND (optional)
Use this keyword to specify the pixel value for the background area. All background
pixels are set to this value. The default value is zero.

DEGREE (optional)
Use this optional keyword to specify the degree of the polynomial warp when the
WARP_METHOD keyword is set to either 3 (Polynomial with Nearest Neighbor), 4
(Polynomial with Bilinear), or 5 (Polynomial with Cubic Convolution). The default
setting of this keyword is 1 (DEGREE = 1).

DIMS (optional)
Use this optional keyword to specify the spatial dimensions on which to perform the
operation (the full file is specified by default).

ENVI Reference Guide

ENVI_ENVISAT_GEOREF_DOIT

266

Chapter 2: ENVI Routines

The DIMS keyword is set to a five-element array of long integers with the following
definitions:
Array Element

Description

DIMS[0]

Unused for this function, set to 1

DIMS[1]

The starting X pixel.


Note - The first pixel is number zero.

DIMS[2]

The ending X pixel.

DIMS[3]

The starting Y pixel.


Note - The first pixel is number zero.

DIMS[4]

The ending Y pixel.

F_FID
Use this keyword to specify the file ID for the input file. This ID is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. F_FID is a long
integer with a value greater than zero. An invalid file ID is specified as 1.

GCP_NAME (optional)
Use this keyword to specify the name of the output file to contain the GCPs (Ground
Control Points). If this keyword is not set, the points are not saved to disk.

IN_MEMORY
Set this keyword to store the output in memory. If IN_MEMORY is not set, output is
stored on disk by default.

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output filename for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.
ENVI_ENVISAT_GEOREF_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

267

OUT_PROJ (optional)
Use this optional keyword to specify the projection of the resulting data. OUT_PROJ
cannot be set to the Arbitrary projection. OUT_PROJ is a projection structure
returned from ENVI_PROJ_CREATE or ENVI_GET_PROJECTION. The default
projection is derived from the input data.

POS (optional)
Use this optional keyword to specify an array of band positions indicating the band
numbers on which to perform the operation (all the bands are specified by default).
POS is an array of long integers that range from zero to Nb 1, where Nb is the
number of bands available.

R_FID (optional)
Use this optional keyword to specify a named variable to contain the file ID for the
resulting processed data. This file ID can be used to subsequently access the resulting
processed data.

WARP_METHOD (optional)
Use this optional keyword to specify an integer value that indicates the methods used
to warp and resample the image. The following table shows the values that represent
each possible combination of warping and resampling methods.
Value

ENVI Reference Guide

Warping and Resampling Methods

RST (Rotation, Scaling, and Translation) with


Nearest Neighbor, which is the default setting

RST with Bilinear

RST with Cubic Convolution

Polynomial with Nearest Neighbor

Polynomial with Bilinear

Polynomial with Cubic Convolution

ENVI_ENVISAT_GEOREF_DOIT

268

Chapter 2: ENVI Routines

Value

Warping and Resampling Methods

Triangulation with Nearest Neighbor

Triangulation with Bilinear

Triangulation with Cubic Convolution

ZERO_EDGE (optional)
Set this keyword to specify that the edges outside of any triangles for the
triangulation method are set to the value specified by the BACKGROUND keyword.
The ZERO_EDGE keyword is only used when the WARP_METHOD keyword is set
to either 6 (Triangulation with Nearest Neighbor), 7 (Triangulation with Bilinear), or
8 (Triangulation with Cubic Convolution).
Note
The ZERO_EDGE keyword is set (/ZERO_EDGE or ZERO_EDGE = 1) by
default. To disable this default behavior, explicitly set the ZERO_EDGE keyword
to zero (ZERO_EDGE = 0).

Examples
The following sample lines of code show how to call this routine to georegister a
MERIS file:
fname = $
"MER_FR__2PNIPA20030529_093827_000000502016_00437_06503_0047.N1"
ENVI_OPEN_DATA_FILE, fname, R_FID = fid, /ENVISAT
IF (fid EQ -1) THEN RETURN
; MERIS files have numerous meta files associated with them. The
; last meta file id points to the radiance data for Level 1 and
; reflectance for level 2 products.
fid = fid[N_ELEMENTS(fid) - 1]
ENVI_DOIT, "ENVI_ENVISAT_GEOREF_DOIT", F_FID = fid, /IN_MEMORY

ENVI_ENVISAT_GEOREF_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

269

ENVI_EVF_CLOSE
Use this routine to close an ENVI Vector File (EVF). After an EVF file is opened (or
created), it is important to close it using this routine in order to help conserve the IDL
sessions memory.

Syntax
ENVI_EVF_CLOSE, evf_id

Arguments
Evf_id
The EVF ID for the EVF file to be closed. The EVF ID is returned from either
ENVI_EVF_OPEN (for existing EVF files) or ENVI_EVF_DEFINE_CLOSE (for
newly created EVF files).

Example
pro print_evf_record_info
;
; Open the EVF file can_v1.evf in the
; ENVI_Install_Directory/data/vector
;
evf_fname = can_v1.evf
evf_id = envi_evf_open(evf_fname)
;
; Get the vector information
;
envi_evf_info, evf_id, num_recs=num_recs, $
data_type=data_type, projection=projection, $
layer_name=layer_name
;
; Print information about each record
;
print, Number of Records: ,num_recs
for i=0,num_recs-1 do begin
record = envi_evf_read_record(evf_id, i)
print, Number of nodes in Record + $
strtrim(i+1,2) + : , n_elements(record[0,*])
endfor
;
; Close the EVF file

ENVI Reference Guide

ENVI_EVF_CLOSE

270

Chapter 2: ENVI Routines


;
envi_evf_close, evf_id
end

See Also
ENVI_EVF_DEFINE_CLOSE
ENVI_EVF_OPEN
ENVI_EVF_INFO

ENVI_EVF_CLOSE

ENVI Reference Guide

Chapter 2: ENVI Routines

271

ENVI_EVF_DEFINE_ADD_RECORD
Use this routine to add a record to a new ENVI Vector File (EVF). The new EVF file
must be initialized using ENVI_EVF_DEFINE_INIT.
ENVI_EVF_DEFINE_ADD_RECORD accepts points, polylines, and polygon
records. After all records are defined, close the EVF file with
ENVI_EVF_DEFINE_CLOSE. The EVF ID returned from
ENVI_EVF_DEFINE_CLOSE can then be used to access the new vectors.

Syntax
ENVI_EVF_DEFINE_ADD_RECORD, Evf_ptr, Points

Arguments
Evf_ptr
The pointer to the new EVF file being created that is returned from
ENVI_EVF_DEFINE_INIT.
Note
The evf_ptr pointer is not the same as an ordinary EVF ID.

Points
A 2 column array of XY points that define the vector record being added to the EVF
file. A point record consists of a single XY pair, a polyline record consists of multiple
XY pairs, and a polygon record is a polyline with the first and last points the same.
Points is an array of (2,npts) where [0,*] are the X points and [1,*] are the Y points.
The data type of the XY pairs (or nodes) that define the vector record will
automatically be converted into the data type of the EVF file that was defined in the
call to ENVI_EVF_DEFINE_INIT.
Tip
For points in a Geographic Lat/Lon Projection, remember to arrange the points
vector as [Longitude, Latitude] to conform to the XY order.

ENVI Reference Guide

ENVI_EVF_DEFINE_ADD_RECORD

272

Chapter 2: ENVI Routines

Keywords
PARTS_PTR (optional)
Use this keyword along with the TYPE keyword to maintain multi-part polygons
within the vector data. Multi-part polygons are commonly used to specify holes
within polygons. If your vector data contains multi-part polygons, set this keyword to
the output of the PARTS_PTR keyword to the ENVI_EVF_READ_RECORD
routine.

TYPE (optional)
Use this keyword along with the PARTS_PTR keyword to maintain multi-part
polygons within the vector data. Multi-part polygons are commonly used to specify
holes within polygons. If your vector data contains multi-part polygons, set this
keyword to the output of the TYPE keyword to the ENVI_EVF_READ_RECORD
routine.

Example
pro create_new_evf_file
;
; Create a Geographic projection
; with the default datum and units.
;
proj = envi_proj_create(/geographic)
;
; Define a polyline vector in Lat/Lon coordinates
;
polyline = [ $
-106.904,
41.5887, $
-106.821,
42.2302, $
-106.013,
42.2183, $
-105.206,
41.3749, $
-105.657,
40.5078, $
-105.835,
39.5574, $
-105.170,
38.8447, $
-104.125,
39.4862, $
-103.269,
40.0563, $
-103.269,
40.0682, $
-102.913,
39.0585, $
-102.901,
39.0585, $
-102.901,
39.0348, $
-103.210,
38.4289, $
-103.804,
38.3695 ]
polyline = reform(polyline, 2, 15)

ENVI_EVF_DEFINE_ADD_RECORD

ENVI Reference Guide

Chapter 2: ENVI Routines

273

;
; define a polygon in Lat/Lon coordinates
; (note first and last coords are identical)
;
polygon = [ $
-104.113,
41.6956, $
-103.994,
42.1589, $
-103.934,
41.6838, $
-103.471,
41.8738, $
-103.887,
41.5531, $
-103.863,
41.0185, $
-103.851,
41.0185, $
-104.041,
41.4818, $
-104.041,
41.4937, $
-104.552,
41.2680, $
-104.220,
41.6006, $
-104.422,
42.0995, $
-104.113,
41.6956 ]
polygon = reform(polygon, 2, 13)
;
; define a set of discrete points in Lat/Lon coordinates
;
points = [ $
-106.572,
39.6643, $
-106.643,
39.5218, $
-106.453,
39.4386, $
-106.417,
39.6168, $
-106.595,
39.4386, $
-106.774,
39.2011, $
-106.215,
39.4030, $
-106.393,
39.2961, $
-106.560,
39.1892, $
-106.536,
38.9872, $
-106.227,
39.1417, $
-106.192,
39.1179, $
-106.263,
38.9635, $
-106.073,
39.1298, $
-106.073,
39.2367 ]
points = reform(points, 2, 15)
;
; Initialize the new EVF file
;
evf_ptr = envi_evf_define_init(sample.evf, $
projection=proj, data_type=4, $
layer_name=Sample EVF File)
if (ptr_valid(evf_ptr) eq 0) then return
;
; add the discrete points as individual records
;

ENVI Reference Guide

ENVI_EVF_DEFINE_ADD_RECORD

274

Chapter 2: ENVI Routines


for i=0,14 do $
envi_evf_define_add_record, evf_ptr, points[*,i]
;
; add the polyline record
;
envi_evf_define_add_record, evf_ptr, polyline
;
; add the polygon record
;
envi_evf_define_add_record, evf_ptr, polygon
;
; Finish defining the new EVF file and
; then close the EVF file
;
evf_id = envi_evf_define_close(evf_ptr, /return_id)
envi_evf_close, evf_id
;
; create an attribute file for this new EVF file
;
; records 1-15 are individual points
; record 16 is a polyline
; record 17 is a polygon
;
attributes = replicate( {name:, id:0L}, 17)
for i=0,14 do begin
attributes[i].name = Sample Point + strtrim(i+1,2)
attributes[i].id = i+1
endfor
attributes[15].name = Sample Polyline
attributes[15].id = 16
attributes[16].name = Sample Polygon
attributes[16].id = 17
envi_write_dbf_file, sample.dbf, attributes
end

See Also
ENVI_EVF_CLOSE
ENVI_EVF_DEFINE_CLOSE
ENVI_EVF_DEFINE_INIT
ENVI_PROJ_CREATE
ENVI_WRITE_DBF_FILE

ENVI_EVF_DEFINE_ADD_RECORD

ENVI Reference Guide

Chapter 2: ENVI Routines

275

ENVI_EVF_DEFINE_CLOSE
Use this function to finish defining a newly created ENVI Vector File (EVF). This
routine must be called before the new EVF file can be used. For convenience, it will
optionally return the EVF ID for the newly created EVF file. The EVF file must be
initialized using ENVI_EVF_DEFINE_INIT.

Syntax
Result = ENVI_EVF_DEFINE_CLOSE(Evf_ptr)

Arguments
Evf_ptr
The pointer to the new EVF file being created that is returned from
ENVI_EVF_DEFINE_INIT.

Keywords
RETURN_ID (optional)
Set this keyword to specify that the EVF ID of the newly defined EVF be returned.
This keyword saves the step of having to open the new file using ENVI_EVF_OPEN.

Example
pro create_new_evf_file
;
; Create a Geographic projection
; with the default datum and units.
;
proj = envi_proj_create(/geographic)
;
; Define a polyline vector in Lat/Lon coordinates
;
polyline = [ $
-106.904,
41.5887, $
-106.821,
42.2302, $
-106.013,
42.2183, $
-105.206,
41.3749, $
-105.657,
40.5078, $
-105.835,
39.5574, $

ENVI Reference Guide

ENVI_EVF_DEFINE_CLOSE

276

Chapter 2: ENVI Routines


-105.170,
38.8447, $
-104.125,
39.4862, $
-103.269,
40.0563, $
-103.269,
40.0682, $
-102.913,
39.0585, $
-102.901,
39.0585, $
-102.901,
39.0348, $
-103.210,
38.4289, $
-103.804,
38.3695 ]
polyline = reform(polyline, 2, 15)
;
; define a polygon in Lat/Lon coordinates
; (note first and last coords are identical)
;
polygon = [ $
-104.113,
41.6956, $
-103.994,
42.1589, $
-103.934,
41.6838, $
-103.471,
41.8738, $
-103.887,
41.5531, $
-103.863,
41.0185, $
-103.851,
41.0185, $
-104.041,
41.4818, $
-104.041,
41.4937, $
-104.552,
41.2680, $
-104.220,
41.6006, $
-104.422,
42.0995, $
-104.113,
41.6956 ]
polygon = reform(polygon, 2, 13)
;
; define a set of discrete points in Lat/Lon coordinates
;
points = [ $
-106.572,
39.6643, $
-106.643,
39.5218, $
-106.453,
39.4386, $
-106.417,
39.6168, $
-106.595,
39.4386, $
-106.774,
39.2011, $
-106.215,
39.4030, $
-106.393,
39.2961, $
-106.560,
39.1892, $
-106.536,
38.9872, $
-106.227,
39.1417, $
-106.192,
39.1179, $
-106.263,
38.9635, $
-106.073,
39.1298, $
-106.073,
39.2367 ]
points = reform(points, 2, 15)

ENVI_EVF_DEFINE_CLOSE

ENVI Reference Guide

Chapter 2: ENVI Routines

277

;
; Initialize the new EVF file
;
evf_ptr = envi_evf_define_init(sample.evf, $
projection=proj, data_type=4, $
layer_name=Sample EVF File)
if (ptr_valid(evf_ptr) eq 0) then return
;
; add the discrete points as individual records
;
for i=0,14 do $
envi_evf_define_add_record, evf_ptr, points[*,i]
;
; add the polyline record
;
envi_evf_define_add_record, evf_ptr, polyline
;
; add the polygon record
;
envi_evf_define_add_record, evf_ptr, polygon
;
; Finish defining the new EVF file and
; then close the EVF file
;
evf_id = envi_evf_define_close(evf_ptr, /return_id)
envi_evf_close, evf_id
;
; create an attribute file for this new EVF file
;
; records 1-15 are individual points
; record 16 is a polyline
; record 17 is a polygon
;
attributes = replicate( {name:, id:0L}, 17)
for i=0,14 do begin
attributes[i].name = Sample Point + strtrim(i+1,2)
attributes[i].id = i+1
endfor
attributes[15].name = Sample Polyline
attributes[15].id = 16
attributes[16].name = Sample Polygon
attributes[16].id = 17
envi_write_dbf_file, sample.dbf, attributes
end

ENVI Reference Guide

ENVI_EVF_DEFINE_CLOSE

278

Chapter 2: ENVI Routines

See Also
ENVI_EVF_CLOSE
ENVI_EVF_DEFINE_ADD_RECORD
ENVI_EVF_DEFINE_INIT
ENVI_PROJ_CREATE
ENVI_WRITE_DBF_FILE

ENVI_EVF_DEFINE_CLOSE

ENVI Reference Guide

Chapter 2: ENVI Routines

279

ENVI_EVF_DEFINE_INIT
Use this function to initialize a new ENVI Vector File (EVF). This is a required first
step in defining a new EVF. This function returns a pointer to the new EVF file that
should be used when adding vector records to the file (using
ENVI_EVF_DEFINE_ADD_RECORD) and when completing the new file
definition (using ENVI_EVF_DEFINE_CLOSE). The function allows specification
of an output filename, layer name, data type and projection.
Note
The EVF pointer returned by this function is not the same as an ordinary EVF ID.
When creating a new EVF file, the EVF ID is returned only when the file definition
is completed with the call to ENVI_EVF_DEFINE_CLOSE.

Syntax
Result = ENVI_EVF_DEFINE_INIT(Filename)

Arguments
Filename
A string value that specifies an output file name for the EVF.

Keywords
DATA_TYPE (optional)
Use this keyword to specify the ENVI data type of the file. DATA_TYPE uses the
following IDL convention:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

ENVI Reference Guide

ENVI_EVF_DEFINE_INIT

280

Chapter 2: ENVI Routines

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

If DATA_TYPE is not set, double precision (5) is used.

LAYER_NAME (optional)
Use this keyword to specify a single string name for the EVF layer. Each EVF file
consists of only a single layer. If LAYER_NAME is not set the default is to use New
Layer.

PROJECTION (optional)
Use this optional keyword to specify a map projection. PROJECTION is a projection
structure returned from ENVI_GET_PROJECTION or ENVI_PROJ_CREATE. If
PROJECTION is not set, the default is an Arbitrary projection.

Example
pro create_new_evf_file
;
; Create a Geographic projection
; with the default datum and units.
;
proj = envi_proj_create(/geographic)
;
; Define a polyline vector in Lat/Lon coordinates
;
polyline = [ $
-106.904,
41.5887, $
-106.821,
42.2302, $
-106.013,
42.2183, $
-105.206,
41.3749, $
-105.657,
40.5078, $
-105.835,
39.5574, $
-105.170,
38.8447, $
-104.125,
39.4862, $
-103.269,
40.0563, $
-103.269,
40.0682, $
-102.913,
39.0585, $
-102.901,
39.0585, $
-102.901,
39.0348, $
-103.210,
38.4289, $

ENVI_EVF_DEFINE_INIT

ENVI Reference Guide

Chapter 2: ENVI Routines

281

-103.804,
38.3695 ]
polyline = reform(polyline, 2, 15)
;
; define a polygon in Lat/Lon coordinates
; (note first and last coords are identical)
;
polygon = [ $
-104.113,
41.6956, $
-103.994,
42.1589, $
-103.934,
41.6838, $
-103.471,
41.8738, $
-103.887,
41.5531, $
-103.863,
41.0185, $
-103.851,
41.0185, $
-104.041,
41.4818, $
-104.041,
41.4937, $
-104.552,
41.2680, $
-104.220,
41.6006, $
-104.422,
42.0995, $
-104.113,
41.6956 ]
polygon = reform(polygon, 2, 13)
;
; define a set of discrete points in Lat/Lon coordinates
;
points = [ $
-106.572,
39.6643, $
-106.643,
39.5218, $
-106.453,
39.4386, $
-106.417,
39.6168, $
-106.595,
39.4386, $
-106.774,
39.2011, $
-106.215,
39.4030, $
-106.393,
39.2961, $
-106.560,
39.1892, $
-106.536,
38.9872, $
-106.227,
39.1417, $
-106.192,
39.1179, $
-106.263,
38.9635, $
-106.073,
39.1298, $
-106.073,
39.2367 ]
points = reform(points, 2, 15)
;
; Initialize the new EVF file
;
evf_ptr = envi_evf_define_init(sample.evf, $
projection=proj, data_type=4, $
layer_name=Sample EVF File)
if (ptr_valid(evf_ptr) eq 0) then return
;

ENVI Reference Guide

ENVI_EVF_DEFINE_INIT

282

Chapter 2: ENVI Routines


; add the discrete points as individual records
;
for i=0,14 do $
envi_evf_define_add_record, evf_ptr, points[*,i]
;
; add the polyline record
;
envi_evf_define_add_record, evf_ptr, polyline
;
; add the polygon record
;
envi_evf_define_add_record, evf_ptr, polygon
;
; Finish defining the new EVF file and
; then close the EVF file
;
evf_id = envi_evf_define_close(evf_ptr, /return_id)
envi_evf_close, evf_id
;
; create an attribute file for this new EVF file
;
; records 1-15 are individual points
; record 16 is a polyline
; record 17 is a polygon
;
attributes = replicate( {name:, id:0L}, 17)
for i=0,14 do begin
attributes[i].name = Sample Point + strtrim(i+1,2)
attributes[i].id = i+1
endfor
attributes[15].name = Sample Polyline
attributes[15].id = 16
attributes[16].name = Sample Polygon
attributes[16].id = 17
envi_write_dbf_file, sample.dbf, attributes
end

See Also
ENVI_EVF_CLOSE
ENVI_EVF_DEFINE_ADD_RECORD
ENVI_EVF_DEFINE_CLOSE
ENVI_GET_PROJECTION
ENVI_PROJ_CREATE
ENVI_WRITE_DBF_FILE

ENVI_EVF_DEFINE_INIT

ENVI Reference Guide

Chapter 2: ENVI Routines

283

ENVI_EVF_INFO
Use this routine to get general information about an ENVI Vector File (EVF). After
the EVF file is opened with ENVI_EVF_OPEN (or the EVF ID is returned from
ENVI_EVF_DEFINE_CLOSE) use the appropriate keyword to retrieve the number
of records, layer name, data type and/or projection.

Syntax
ENVI_EVF_INFO, Evf_id

Arguments
Evf_id
The EVF ID returned from ENVI_EVF_OPEN or ENVI_EVF_DEFINE_CLOSE.

Keywords
DATA_TYPE (optional)
Use this keyword to specify a named variable that will contain the ENVI data type of
the vector file. DATA_TYPE uses the following IDL convention:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

ENVI Reference Guide

ENVI_EVF_INFO

284

Chapter 2: ENVI Routines

LAYER_NAME (optional)
Use this keyword to specify a named variable that will contain the string name for the
EVF layer. Each EVF file consists of only a single layer.

NUM_RECS (optional)
Use this keyword to specify a named variable that will contain the number of vector
records in the EVF file.

PROJECTION (optional)
Use this keyword to specify a named variable that will contain the projection
information for the EVF data. The information is returned in a projection structure as
defined by ENVI_PROJ_CREATE.

Example
pro print_evf_record_info
;
; Open the EVF file can_v1.evf in the
; ENVI_Install_Directory/data/vector
;
evf_fname = can_v1.evf
evf_id = envi_evf_open(evf_fname)
;
; Get the vector information
;
envi_evf_info, evf_id, num_recs=num_recs, $
data_type=data_type, projection=projection, $
layer_name=layer_name
;
; Print information about each record
;
print, Number of Records: ,num_recs
for i=0,num_recs-1 do begin
record = envi_evf_read_record(evf_id, i)
print, Number of nodes in Record + $
strtrim(i+1,2) + : , n_elements(record[0,*])
endfor
;
; Close the EVF file
;
envi_evf_close, evf_id
end

ENVI_EVF_INFO

ENVI Reference Guide

Chapter 2: ENVI Routines

285

See Also
ENVI_EVF_CLOSE
ENVI_EVF_DEFINE_CLOSE
ENVI_EVF_OPEN
ENVI_PROJ_CREATE

ENVI Reference Guide

ENVI_EVF_INFO

286

Chapter 2: ENVI Routines

ENVI_EVF_OPEN
Use this function to open an existing ENVI Vector File (EVF). You can use
ENVI_EVF_DEFINE_INIT to create a new EVF file. This function returns the EVF
ID which is used to access data from the file using ENVI_EVF_INFO and
ENVI_EVF_READ_RECORD. When finished using an EVF file, always remember
to properly close the file using ENVI_EVF_CLOSE.

Syntax
Result = ENVI_EVF_OPEN(Filename)

Arguments
Filename
A string value that specifies the EVF file name.

Example
pro print_evf_record_info
;
; Open the EVF file can_v1.evf in the
; ENVI_Install_Directory/data/vector
;
evf_fname = can_v1.evf
evf_id = envi_evf_open(evf_fname)
;
; Get the vector information
;
envi_evf_info, evf_id, num_recs=num_recs, $
data_type=data_type, projection=projection, $
layer_name=layer_name
;
; Print information about each record
;
print, Number of Records: ,num_recs
for i=0,num_recs-1 do begin
record = envi_evf_read_record(evf_id, i)
print, Number of nodes in Record + $
strtrim(i+1,2) + : , n_elements(record[0,*])
endfor
;
; Close the EVF file

ENVI_EVF_OPEN

ENVI Reference Guide

Chapter 2: ENVI Routines

287

;
envi_evf_close, evf_id
end

See Also
ENVI_EVF_CLOSE
ENVI_EVF_DEFINE_INIT
ENVI_EVF_INFO
ENVI_EVF_READ_RECORD

ENVI Reference Guide

ENVI_EVF_OPEN

288

Chapter 2: ENVI Routines

ENVI_EVF_READ_RECORD
Use this function to retrieve records from an ENVI Vector File (EVF). After the EVF
file is opened with ENVI_EVF_OPEN (or the EVF ID is returned from
ENVI_EVF_DEFINE_CLOSE) the specified record can be retrieved. The routine
ENVI_EVF_INFO is used to get the number of records.

Syntax
Result = ENVI_EVF_READ_RECORD(Evf_id, Record_number)

Arguments
Evf_id
The EVF ID returned from ENVI_EVF_OPEN or ENVI_EVF_DEFINE_CLOSE.

Record_number
The record number for the vector to retrieve. Record_number is a long integer value
from zero to the total number of records less one (NUM_RECS - 1). The
NUM_RECS value is retrieved using ENVI_EVF_INFO.

Keywords
PARTS_PTR (optional)
Use this keyword along with the TYPE keyword to maintain multi-part polygons
within the vector data. Multi-part polygons are commonly used to specify holes
within polygons. If your vector data contains multi-part polygons, set this keyword to
a named variable, then set the PARTS_PTR keyword of the
ENVI_EVF_DEFINE_ADD_RECORD routine to this resulting variable.

TYPE (optional)
Use this keyword along with the PARTS_PTR keyword to maintain multi-part
polygons within the vector data. Multi-part polygons are commonly used to specify
holes within polygons. If your vector data contains multi-part polygons, set this
keyword to a named variable, then set the TYPE keyword of the
ENVI_EVF_DEFINE_ADD_RECORD routine to this resulting variable.

ENVI_EVF_READ_RECORD

ENVI Reference Guide

Chapter 2: ENVI Routines

289

Example
pro print_evf_record_info
;
; Open the EVF file can_v1.evf in the
; ENVI_Install_Directory/data/vector
;
evf_fname = can_v1.evf
evf_id = envi_evf_open(evf_fname)
;
; Get the vector information
;
envi_evf_info, evf_id, num_recs=num_recs, $
data_type=data_type, projection=projection, $
layer_name=layer_name
;
; Print information about each record
;
print, Number of Records: ,num_recs
for i=0,num_recs-1 do begin
record = envi_evf_read_record(evf_id, i)
print, Number of nodes in Record + $
strtrim(i+1,2) + : , n_elements(record[0,*])
endfor
;
; Close the EVF file
;
envi_evf_close, evf_id
end

See Also
ENVI_EVF_CLOSE
ENVI_EVF_DEFINE_CLOSE
ENVI_EVF_INFO
ENVI_EVF_OPEN

ENVI Reference Guide

ENVI_EVF_READ_RECORD

290

Chapter 2: ENVI Routines

ENVI_EVF_TO_SHAPEFILE
This new batch routine enables you to output ENVI vector files (EVF) to ArcView
shapefile formats. The shapefile format consists of files with .shp, .shx, and .dbf
extensions.
A single EVF file may contain points, polylines, polygons and/or multi-point records
all in the same file. A shapefile, on the other hand, may only contain one record type
per file. If the EVF file contains only a single type of record, then the resulting
shapefile output from ENVI_EVF_TO_SHAPEFILE consists of three files:
rootname.shp,
rootname.shx,
rootname.dbf,

where rootname is the output_shapefile_rootname argument string.


If the EVF file specified by the evf_id argument contains multiple record types, then
the output of ENVI_EVF_TO_SHAPEFILE is a separate shapefile for each record
type. For instance, if an EVF has any point, polyline, polygon, or multipoint records,
the resulting files for a shapefile named rootname are:
rootname_point.shp

for point records

rootname_polyline.shp

for polyline records

rootname_polygon.shp

for polygon records

rootname_multipoint.shp

for multipoint records

If the EVF file contains associated attributes, these attributes are contained in the
rootname.dbf file. However, if there are no attributes, a dummy record ID column

is used.

Syntax
ENVI_EVF_TO_SHAPEFILE, evf_id, output_shapefile_rootname

Arguments
evf_id
The EVF file ID returned from ENVI_EVF_OPEN.

ENVI_EVF_TO_SHAPEFILE

ENVI Reference Guide

Chapter 2: ENVI Routines

291

Note
The evf_id argument may be an array of IDs as long as output_shapefile_rootname
is a string array of the same number of elements. There must be one output root
name per evf_id.

output_shapefile_rootname
The string root name for the resulting shapefiles. Because the shapefile output
consists of multiple files with specific extensions, there is no need to include the
.shp extension as part of this string.
Warning
Because EVF files also use a *.dbf file to store attributes, the output shapefile
name must be different than the name of the EVF file. In other words, if an EVF is
named foo.evf, then the output_shapefile_rootname argument should not be foo
if the two formats (.evf, .shp) are to reside in the same directory.

Keywords
None

ENVI Reference Guide

ENVI_EVF_TO_SHAPEFILE

292

Chapter 2: ENVI Routines

ENVI_FILE_MNG
This procedure is used to manage ENVI files in memory and on disk.

Syntax
ENVI_FILE_MNG

Keywords
DELETE (optional)
Set this optional keyword to delete the specified file from the hard disk.

ID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero.

REMOVE
Set this keyword to remove the specified file from within ENVI.

Example
Remove the file specified by FID from ENVI and delete it from the disk.
envi_file_mng, id=fid, /remove, /delete

See Also
ENVI_GET_FILE_IDS

ENVI_FILE_MNG

ENVI Reference Guide

Chapter 2: ENVI Routines

293

ENVI_FILE_QUERY
This procedure gets file information from the header file of the file being queried. If
no header exists then the standard ENVI widget for entering file header information
appears, the user enters the pertinent information, and execution of the function is
continued by clicking on the Accept button.

Syntax
ENVI_FILE_QUERY, Fid

Arguments
Fid
The file ID for the open file. This is the value returned from the keyword R_FID in
the ENVI_OPEN_FILE procedure. Fid is a long integer with a value greater than
zero. An invalid file ID is specified as -1.

Keywords
BBL (optional)
Use this optional keyword to specify a named variable that will contain an array of
ones and zeros representing the bad band list. A 1 represents a good band and a 0
represents a bad band. If no bad bands list is available for the data, the value 1 is
returned. Otherwise, the number of elements of BBL is equal to the number of bands,
NB.

BNAMES (optional)
Use this optional keyword to specify a named variable that will contain the band
names associated with each band.

BYTE_SWAP (optional)
Use this optional keyword to specify a named variable that will contain the byte swap
value for the data. If BYTE_SWAP is set, then the byte order of the data specified by
FID is different than the current processor. User specified spatial and spectral read
routines will need to BYTEORDER the data after reading from disk.

ENVI Reference Guide

ENVI_FILE_QUERY

294

Chapter 2: ENVI Routines

CLASS_NAMES (optional)
Use this optional keyword to specify a named variable that will contain the class
names for classification images. CLASS_NAMES is only set when the queried file is
type ENVI Classification, otherwise the value is undefined.

DATA_GAINS (optional)
Use this optional keyword to specify a named variable to contain an array of gains for
each band in the data set. DATA_GAINS is an array of values, one for each band.
DATA_GAINS can be used in conjunction with DATA_OFFSETS in ENVIs General
Purpose Utility - Apply Gain and Offset. If the gains are undefined for the input file,
nothing is returned for the DATA_GAINS keyword.

DATA_IGNORE_VALUE (optional)
Use this optional keyword to specify a named variable to contain a scalar number
representing the data value to ignore in the data set. If set, DATA_IGNORE_VALUE
is the same type as the input data set and an undefined ignore value is represented by
the double precision number 1e-34. Currently, this value is used only in user-written
ENVI code. If the data ignore value is undefined for the input file, nothing is returned
for the DATA_IGNORE_VALUE keyword.

DATA_OFFSETS (optional)
Use this optional keyword to specify a named variable to contain an array of offsets
for each band in the data set. DATA_OFFSETS is an array of values, one for each
band. DATA_OFFSETS can be used in conjunction with DATA_GAINS in ENVIs
General Purpose Utility - Apply Gain and Offset. If the offsets are undefined for the
input file, nothing is returned for the DATA_OFFSETS keyword.

DATA_TYPE (optional)
Use this optional keyword to specify a named variable that will contain the IDL data
type of the file, using the following IDL convention:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

ENVI_FILE_QUERY

ENVI Reference Guide

Chapter 2: ENVI Routines

295

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

DEF_ZRANGE (optional)
Use this optional keyword to specify a named variable that will contain a twodimensional array equal to the lower and upper plot ranges used as the default in
spectral plots.

DEF_STRETCH (optional)
Use this optional keyword to specify a named variable that will contain the default
stretch. The default stretch is used when displaying a band from the file.
DEF_STRETCH is the structure created by
ENVI_DEFAULT_STRETCH_CREATE.

DESCRIP (optional)
Use this optional keyword to specify a named variable that will contain a string
description of the file.

DIMS (optional)
Use this optional keyword to specify a named variable to contain the spatial
dimensions of the file. The DIMS keyword returns a five-element array of long
integers with the following definitions:
Array Element

ENVI Reference Guide

Value

DIMS[0]

DIMS[1]

DIMS[2]

ns 1, where ns
is the number of
samples

ENVI_FILE_QUERY

296

Chapter 2: ENVI Routines

Array Element

Value

DIMS[3]

DIMS[4]

nl 1, where nl
is the number of
lines

FILE_TYPE (optional)
Use this optional keyword to specify a named variable that will contain the integer
file type value. See ENVI_FILE_TYPE on page 301 for details on how to test for a
given file type.

FNAME (optional)
Use this optional keyword to specify a named variable that will contain the file name,
including the path, associated with the file. For memory items, the FNAME contains
a string indicating the memory item number and its associated spatial and spectral
dimensions.

FUNC_COMPLEX (optional)
Set this optional keyword to the Complex Lookup Function to determine how to
display complex data. This keyword should be set to one of the following:
0

Power

The natural log of the magnitude, ln(magnitude).


(Default)

Magnitude

Real

The real portion of the complex number.

Imaginary

The imaginary part of the complex number.

Phase

imag inary
arc tan -------------------------real

( real ) + ( imag inary )

Note
Only set this keyword if the IDL data type of the image is 6 = complex (2 x 32-bit)
or 9 = double-precision complex (2 x 64-bit).

ENVI_FILE_QUERY

ENVI Reference Guide

Chapter 2: ENVI Routines

297

FWHM (optional)
Use this optional keyword to specify a named variable that will contain an array of
full-width-half-maximum values, one for each band. If there is no FWHM associated
with the file then -1 is returned.

H_INFO (optional)
Use this optional keyword to specify a named variable that will contain a handle
pointer to user-defined header information. Use the routine HANDLE_VALUE to
retrieve the information. The value of the handle is set equal to the INFO keyword in
ENVI_SETUP_HEAD or ENVI_ENTER_DATA.

INTERLEAVE (optional)
Use this optional keyword to specify a named variable that will contain the files
interleave type. If the file is in BSQ format, this variable is set to zero. If BIL format,
it is set to one. If BIP format, it is set to two.

LOOKUP (optional)
Use this optional keyword to specify a named variable that will contain the RGB
lookup values for each class in a classification image. The returned result is a byte
array [3,NUM_CLASSES]. LOOKUP is only set when the queried file is type ENVI
Classification, otherwise the value -1 is returned.

LUT_NAME (optional)
Use this optional keyword to specify a named variable that will contain the filename
of the lookup table for the data.

NB (optional)
Use this optional keyword to specify a named variable that will contain the number of
bands in the file.

NL (optional)
Use this optional keyword to specify a named variable that will contain the number of
lines in the file.

NS (optional)
Use this optional keyword to specify a named variable that will contain the number of
samples in the file.

ENVI Reference Guide

ENVI_FILE_QUERY

298

Chapter 2: ENVI Routines

NUM_CLASSES (optional)
Use this optional keyword to specify a named variable that will contain the number of
classes for classification images. NUM_CLASSES is only set when the queried file is
type ENVI Classification, otherwise the value 0 is returned.

OFFSET (optional)
Use this optional keyword to specify a named variable that will contain the offset in
bytes to the start of the data in the file.

READ_PROCEDURE (optional)
Use this optional keyword to specify a named variable that will contain a twoelement string array of the procedure names for the spatial and spectral readers,
respectively. The ENVI read procedures provide for a powerful mechanism for
importing custom formats or files directly into ENVI without the need for
conversion. All spatial or spectral requests for data go through the specified read
routines.

REFLECTANCE_SCALE_FACTOR (optional)
Use this optional keyword to specify a named variable to contain a single scalar
number used to convert the input data into reflectance. For example,
REFLECTANCE_SCALE_FACTOR would be used to convert integer scaled
reflectance data into their floating point [0, 1] reflectance values. If the scale factor is
undefined for the input file, nothing is returned for the this keyword.

SENSOR_TYPE (optional)
Use this optional keyword to specify a named variable that will contain the integer
sensor type value. See ENVI_SENSOR_TYPE on page 452 for details on how to
test for a given sensor type.

SNAME (optional)
Use this optional keyword to specify a named variable that will contain the shortened
file name (without the path). For memory items, SNAME contains an empty string.

SPEC_NAMES (optional)
Use this optional keyword to specify a named variable that will contain a string array
of spectral library names. SPEC_NAMES is only set when the queried file is a
spectral library.

ENVI_FILE_QUERY

ENVI Reference Guide

Chapter 2: ENVI Routines

299

STA_NAME (optional)
Use this optional keyword to specify a named variable that will contain the statistics
file name. If no filename is specified the STA_NAME is equal to the empty string, .

WAVELENGTH_UNITS (optional)
Use this optional keyword to specify a named variable to contain a value indicating
the wavelength units. The valid values are one of the following:

0 Micrometers

1 Nanometers

2 Wavenumber

3 GHz

4 MHz

5 Index

6 Unknown

WL (optional)
Use this optional keyword to specify a named variable that will contain an array of
wavelength values, one for each band. If there is no wavelength associated with the
file, then -1 is returned.

XSTART (optional)
Use this optional keyword to specify a named variable that will contain the X starting
sample for the first pixel in the file.

YSTART (optional)
Use this optional keyword to specify a named variable that will contain the Y starting
row for the first pixel in the file.

ENVI Reference Guide

ENVI_FILE_QUERY

300

Chapter 2: ENVI Routines

Example
This example prompts the user for a file using ENVI_SELECT. Next,
ENVI_FILE_QUERY is used to retrieve the file information for the number of
samples, lines and bands, the filename, data type, and interleave. The results are then
printed to the screen.
ENVI_SELECT, fid=fid
ENVI_FILE_QUERY, fid, ns=ns, nl=nl, nb=nb, $
fname=fname, data_type=data_type, $
interleave=interleave
print,
print,
print,
print,

Filename = , fname
ns= , ns, nl =, nl, nb =, nb
interleave = , interleave
data type = , data_type

See Also
ENVI_DISP_QUERY
ENVI_ENTER_DATA
ENVI_SETUP_HEAD

ENVI_FILE_QUERY

ENVI Reference Guide

Chapter 2: ENVI Routines

301

ENVI_FILE_TYPE
ENVI files may conform to any of a range of different file types. This function
returns a file type descriptor. All ENVI files that require special display or input
processing have a unique file type (Meta File, Virtual Mosaic, Classification, Spectral
Library, FFT Result). Any external file that requires an input read routine also has a
designated file type.

Syntax
Result = ENVI_FILE_TYPE(File_type)

Arguments
File_type
File_type can be either an integer or a string.

If File_type is an integer, it is the value for file type as returned by


ENVI_FILE_QUERY. In this case, the returned value is a string.

If File_type is a string, the function returns an arbitrarily assigned integer


which can be used in routines such as ENVI_SETUP_HEAD or
ENVI_ENTER_DATA.

The file types and string descriptors are found in Table 12-3. File_type string
descriptors are case-sensitive and may contain spaces.
File Type

String Descriptor

ENVI Standard

ENVI Standard

ENVI Meta File

ENVI Meta File

ENVI Virtual Mosaic

ENVI Virtual Mosaic

ENVI Classification

ENVI Classification

ENVI Spectral Library

ENVI Spectral Library

ENVI Fast Fourier Transform

ENVI FFT

Australian Centre for Remote Sensing CEOS

ACRES CEOS

Table 12-3: File Types and String Descriptors

ENVI Reference Guide

ENVI_FILE_TYPE

302

Chapter 2: ENVI Routines

File Type

String Descriptor

ARC Digitized Raster Graphics

ADRG

AVHRR LAC/HRPT, GAC Data

AVHRR CD

BMP

BMP

CEOS Generic

CEOS Generic

ENVISAT

ENVISAT

ERDAS 8.X

ERDAS 8.X

ERDAS IMAGINE

ERDAS IMAGINE

European Space Agency Landsat TM

ESA Landsat TM

ESA SHARP

ESA SHARP

ESRI GRID

ESRI GRID

HDF EOS ASTER

HDF EOS ASTER

HDF EOS MODIS

HDF EOS MODIS

HDF Landsat

HDF Landsat

HDF Modis Simulator

HDF Modis Simulator

HDF Scientific Data and Raster

HDF SD

HDF SeaWiFS

HDF SeaWiFS

JPEG2000

JPEG2000

Multi-Resolution Seamless Image Database

MrSID

National Imagery Transmission Format

NITF

National Landsat Archive Production System CD NLAPS CD


NOAA DMSP

NOAA DMSP

PCI

PCI

Planetary Data System Image

PDS Image

RADARSAT

RADARSAT

Table 12-3: File Types and String Descriptors

ENVI_FILE_TYPE

ENVI Reference Guide

Chapter 2: ENVI Routines

303

File Type

String Descriptor

SPOT CD

SPOT CD

TIFF and GeoTIFF

TIFF

Tiled QuickBird

Tiled QB

Table 12-3: File Types and String Descriptors

Keywords
None

Examples
The following example prints the file type string of the file associated with the file ID
fid. The first command stores the integer file type descriptor in the variable
file_type:
envi_file_query, fid, file_type=file_type

The next line stores the string file type descriptor in the variable TYPE_STRING:
type_string = envi_file_type(file_type)
print, type_string

The next example enters the array DATA into ENVI and sets the file type to SPOT
data. The first line gets the integer file type for SPOT data. The second line enters the
array.
file_type = envi_file_type(SPOT)
envi_enter_data, DATA, file_type=file_type

See Also
ENVI_FILE_QUERY
ENVI_SENSOR_TYPE

ENVI Reference Guide

ENVI_FILE_TYPE

304

Chapter 2: ENVI Routines

ENVI_FILTER_DOIT
Use this program to build an FFT filter image.

Syntax
ENVI_DOIT, ENVI_FILTER_DOIT

Keywords
ANN_NAME
Use this keyword to specify an annotation file name for user defined filters. This
keyword is not used for circular or band pass filters.

FILTER
Use this keyword to specify an integer value corresponding to the filter type to build.
Choose one of the following;

0 Circular Pass Filter

1 Circular Cut Filter

2 Band Pass Filter

3 Band Cut Filter

4 User Defined Pass Filter

5 User Defined Cut Filter

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

NBP
Use this keyword to specify the number of boarder pixels for the filter transitions.

NS
Use this keyword to specify the number of samples in the output filter image.

ENVI_FILTER_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

305

NL
Use this keyword to specify the number of lines in the output filter image.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

RADIUS
For circular filters, this keyword specifies the filter radius in pixels. For band pass
filters, this keyword is a two-element array specifying the inner and outer filter radius
in pixels. This keyword is not used for user defined filters.

Example
pro example_envi_filter_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the necessary variables
;
ns = 512L
nl = 512L
radius = [60,150]
out_name =testfilter.img
;
; Call the doit
;
envi_doit, envi_filter_doit, $
ns=ns, nl=nl, filter=2, $
radius=radius, nbp=0, $
out_name=out_name, r_fid=r_fid
;

ENVI Reference Guide

ENVI_FILTER_DOIT

306

Chapter 2: ENVI Routines


; Exit ENVI
;
envi_batch_exit
end

ENVI_FILTER_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

307

ENVI_GEOREF_FROM_GLT_DOIT
The ENVI_GEOREF_FROM_GLT_DOIT procedure georeferences a file from a
GLT file. The GLT file contains the map projection information for the specified
input file. Each pixel location in the input file is directly mapped to a specified output
map location. The routine ENVI_GLT_DOIT is used to build the input GLT file.

Syntax
ENVI_DOIT, ENVI_GEOREF_FROM_GLT_DOIT [, BACKGROUND=value]
, FID=fileID [, GLT_DIMS=array], GLT_FID=fileID, /IN_MEMORY
| OUT_NAME=string [, KERNEL_MAX=value] [, KERNEL_MIN=value]
[, MIN_PIXELS=value], POS=array [, R_FID=variable] [, SGL_NAME=string
, /SUPER] [, /SUBSET]

Arguments
None

Keywords
BACKGROUND (optional)
Use this keyword to specify the pixel value for the background area. All background
pixels will be set to this value. The default is zero.

FID
Use this keyword to specify the file ID for the input file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

GLT_DIMS (optional)
Use this keyword to specify the spatial dimensions of the input file on which the
operation is performed. If the keyword SUPER is set, the GLT_DIMS keyword is
ignored. If this keyword is not set, the operation is performed on the entire input file.
GLT_DIMS is a five-element array of long integers with the following definitions:

DIMS[0]:Unused for this function, set to -1.

DIMS[1]:The starting X pixel. (The first pixel is number zero.)

ENVI Reference Guide

ENVI_GEOREF_FROM_GLT_DOIT

308

Chapter 2: ENVI Routines

DIMS[2]:The ending X pixel.

DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

DIMS[4]:The ending Y pixel.

GLT_FID
Use this keyword to specify the file ID for the input GLT file. This is the value
returned from the keyword R_FID in the ENVI_OPEN_FILE procedure. GLT_FID is
a long integer with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

KERNEL_MAX (optional)
Use this keyword to specify the maximum kernel size, which is used with
KERNEL_MIN as resampling parameters.

KERNEL_MIN (optional)
Use this keyword to specify the minimum kernel size, which is used in the
resampling unless fewer than the minimum number of pixels to resample, or valid
pixels, are contained in the kernel. If fewer than the minimum number of valid pixels
are contained in the kernel, the kernel size is increased until either the minimum
number of valid pixels is met or the maximum kernel size is met. If there are fewer
than the minimum number of valid pixels in the maximum kernel size then the output
pixel value will be set to the background value.

MIN_PIXELS (optional)
Use this keyword to specify the minimum number of pixels. If fewer than the
minimum number of pixels are contained in the maximum kernel size then the output
pixel value will be set to the background value.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

ENVI_GEOREF_FROM_GLT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

309

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

SGL_NAME (optional)
Set this keyword to the filename of the Super GLT file (on disk) that results from
GLT_DOIT. This keyword is required if the SUPER keyword is set.

SUBSET (optional)
Set this optional keyword to indicate that the file specified by FID is a subset of the
GLT file. Output dimensions will be determined by the minimum and maximum
samples and lines of the GLT file. If this keyword is specified then GLT_DIMS is
ignored.

SUPER (optional)
Set this optional keyword to perform a Super GLT operation. If this keyword is set
then SGL_NAME must also be specified.

UNDEFINED (optional)
Set this optional keyword to a named variable to contain either 0 or 1. A value of 0
indicates the returned projection is valid. A value of 1 indicates no projection exists
for the given DN or FID and the resulting map information structure is invalid.
pro example_glt_usage
compile_opt strictarr
; Select an image and its associated input geometry.
envi_select, title=Please select an image to georeference, $
dims=dims, fid=fid, pos=pos
if fid eq -1 then return
envi_select, title=Please select the longitude band, $
fid=x_fid, dims=dims, pos=x_pos, /band_only, /no_dims
if x_fid eq -1 then return
envi_select, title=Please select the latitude band, $
fid=y_fid, dims=dims, pos=y_pos, /band_only, /no_dims

ENVI Reference Guide

ENVI_GEOREF_FROM_GLT_DOIT

310

Chapter 2: ENVI Routines


if y_fid eq -1 then return
; Figure out what UTM zone were in.
query_dims = [-1L, long(dims[2]/2), long(dims[2]/2),
long(dims[4]/2), long(dims[4]/2)]
lat_lon = [envi_get_data(fid=y_fid, dims=query_dims, pos=y_pos), $
envi_get_data(fid=x_fid, dims=query_dims, pos=x_pos)]
zone = fix(31.0 + lat_lon[1]/6.0)
south = (lat_lon[0] lt 0)
; Make the GLT.
envi_file_query, fid, sname=sname
out_name=sname+_glt
pixel_size=[1000.0D, 1000.0]
rotation=0.0
i_proj = envi_proj_create(/geographic)
o_proj = envi_proj_create(/utm, zone=zone, south=south)
envi_glt_doit, i_proj=i_proj, $
o_proj=o_proj, out_name=out_name, $
pixel_size=pixel_size, r_fid=glt_fid, $
rotation=rotation, x_fid=x_fid, y_fid=y_fid, $
x_pos=x_pos, y_pos=y_pos
if glt_fid eq -1 then return
; Georeference the image from the GLT.
out_name=sname+_georef
envi_doit, envi_georef_from_glt_doit, fid=fid, $
glt_fid=glt_fid, out_name=out_name, pos=pos, $
subset=dims, r_fid=r_fid
end

See Also
ENVI_GLT_DOIT
ENVI_REGISTER_DOIT

ENVI_GEOREF_FROM_GLT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

311

ENVI_GET_CONFIGURATION_VALUES
Use this function to get the current setting for all the ENVI configuration items. This
function returns an anonymous structure of the current configuration settings. The tag
names of the structure are the configuration item and the values are the current
setting.

Syntax
Result = ENVI_GET_CONFIGURATION_VALUES

Example
This example retrieves the current ENVI configuration values.
cfg = envi_get_configuration_values()
help, cfg, /structure

ENVI Reference Guide

ENVI_GET_CONFIGURATION_VALUES

312

Chapter 2: ENVI Routines

ENVI_GET_DATA
Use this function to retrieve spatial image data for any open file. The DIMS keyword
allows full control over the spatial dimensions of the returned data allowing retrieval
of both the full band or any spatial subset. The band is specified with the POS
keyword and only a single band is returned. Additional optional parameters allow
automatic resampling of the spatial data to smaller or larger pixels sizes. This
function will work with any image open in ENVI regardless of the format or physical
storage order of the file.
This routine, along with ENVI_GET_SLICE, can be used in place of tiled
processing. However, requests for large images may be limited by the amount of your
system RAM available.

Syntax
Result = ENVI_GET_DATA()

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-elements array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned by
the R_FID keyword to the ENVI_OPEN_FILE procedure. FID is a long integer with
a value greater than zero. An invalid file ID is specified as -1.

ENVI_GET_DATA

ENVI Reference Guide

Chapter 2: ENVI Routines

313

INTERP (optional)
Use this optional keyword to specify an integer value corresponding to the
interpolation type. The keyword is only used when either XFACTOR or YFACTOR
is not equal to 1. Choose one of the following.

0 Nearest Neighbor

1 Bilinear

2 Cubic Convolution

3 Pixel Aggregate

POS
Use this keyword to specify the band position of the returned data. POS is a long
integer with a value from zero to number-of-bands minus one.

XFACTOR (optional)
Use this optional keyword to specify the X magnification factor for the data. A value
of one does not change the data. Values greater than one cause the size to increase,
values less than one cause the size to decrease.

YFACTOR (optional)
Use this optional keyword to specify the Y magnification factor for the data. A value
of one does not change the data. Values greater than one cause the size to increase,
values less than one cause the size to decrease.

ENVI Reference Guide

ENVI_GET_DATA

314

Chapter 2: ENVI Routines

Example
This example will open a file, determine its spatial size, and request that all of the
data for the first band be stored in the variable DATA. The routine
ENVI_OPEN_FILE is used to programmatically open the desired file. Subsequent
references to this file will use the file ID returned in the keyword R_FID. Once the
file is open ENVI_FILE_QUERY is used to determine the number of samples and
number of lines. The samples and lines are used to set the DIMS keyword for the
function ENVI_GET_DATA. A call to ENVI_GET_DATA with the full band
specified by DIMS and the first band specified by POS returns all image data for the
first band in a Samples-by-Lines 2-D array.
ENVI_OPEN_FILE, can_tmr.img, r_fid=fid
ENVI_FILE_QUERY, fid, ns=ns, nl=nl
dims = [-1, 0, ns-1, 0, nl-1]
data = ENVI_GET_DATA(fid=fid, dims=dims, pos=0)

See Also
ENVI_GET_IMAGE
ENVI_INIT_TILE
ENVI_OPEN_FILE
ENVI_GET_SLICE

ENVI_GET_DATA

ENVI Reference Guide

Chapter 2: ENVI Routines

315

ENVI_GET_DISPLAY_NUMBERS
Use this function to get a list of display numbers. The optional keywords can be used
to specify displays that are loaded, only displays with color images, and/or only
displays with georeferenced images.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = ENVI_GET_DISPLAY_NUMBERS()

Keywords
COLOR (optional)
Set this keyword to specify that the function return only displays with RGB color
images. This keyword can be used in conjunction with the other keywords.

GEOREF (optional)
Set this keyword to specify that the function return only displays with georeferenced
images.This keyword can be used in conjunction with the other keywords.

LOADED (optional)
Set this keyword to specify that the function return only displays which are loaded
with an image.This keyword can be used in conjunction with the other keywords.

ENVI Reference Guide

ENVI_GET_DISPLAY_NUMBERS

316

Chapter 2: ENVI Routines

ENVI_GET_FILE_IDS
This function returns an array of file IDs for all open ENVI files. A file ID is a long
integer with a value greater than zero. If no files are open then a -1 is returned.
Note
More than one file ID may be associated with a single open file in ENVI. For
example, if ENVI_GET_FILE_IDS is applied a virtual mosaic, this function returns
not only the file ID of the virtual mosaic but also the IDs of the files used to create
the mosaic.

Syntax
Result = ENVI_GET_FILE_IDS()

Keywords
None

Example
This example get all the file IDs and prints out the corresponding filename.
fids = envi_get_file_ids()
if (fids[0] eq -1) then return
for i = 0, n_elements(fids) - 1 do begin
envi_file_query, fids[i], fname = fname
print, fname
endfor

See Also
ENVI_FILE_MNG
ENVI_FILE_QUERY
ENVI_OPEN_FILE

ENVI_GET_FILE_IDS

ENVI Reference Guide

Chapter 2: ENVI Routines

317

ENVI_GET_HEADER_VALUE
Use this procedure to retrieve user defined header values. Using the routine
ENVI_FILE_QUERY, all the standard header information is available to the user;
however, to access user defined header values you must use the routine
ENVI_GET_HEADER_VALUE. By supplying the user defined keyword,
ENVI_GET_HEADER_VALUE will return the associated header values. Optional
keywords allow setting of the returned data type.

Syntax
Result = ENVI_GET_HEADER_VALUE(Fid, User_Keyword)

Arguments
Fid
The file ID for the open file. This is the value returned from the keyword R_FID in
the ENVI_OPEN_FILE procedure. Fid is a long integer with a value greater than
zero. An invalid file ID is specified as -1.

User_Keyword
The user defined keyword string. User_Keyword is a case insensitive string value
that must match exactly to the full user defined keyword (including spaces).

Keywords
BYTE (optional)
Set this keyword to specify that the User_Keyword value(s) be returned as a byte
number(s). This keyword should not be set if the keywords DOUBLE, DT, FIX,
FLOAT, L64, LONG, UL64, or ULONG are used. The default is to return the
value(s) as a string.

DOUBLE (optional)
Set this keyword to specify that the User_Keyword value(s) be returned as a double
precision number(s). This keyword should not be set if the keywords BYTE, DT,
FIX, FLOAT, L64, LONG, UL64, or ULONG are used. The default is to return the
value(s) as a string.

ENVI Reference Guide

ENVI_GET_HEADER_VALUE

318

Chapter 2: ENVI Routines

DT (optional)
Use this optional keyword to specify the IDL data type for the returned
User_Keyword value(s). The valid IDL data type conventions are:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer

The default is to return the value(s) as a string.

FIX (optional)
Set this keyword to specify that the User_Keyword value(s) be returned as an integer
number(s). This keyword should not be set if the keywords BYTE, DOUBLE, DT,
FLOAT, L64, LONG, UL64, or ULONG are used. The default is to return the
value(s) as a string.

FLOAT (optional)
Set this keyword to specify that the User_Keyword value(s) be returned as a floating
point number(s). This keyword should not be set if the keywords BYTE, DOUBLE,
DT, FIX, L64, LONG, UL64, or ULONG are used. The default is to return the
value(s) as a string.

L64 (optional)
Set this keyword to specify that the User_Keyword value(s) be returned as a 64-bit
integer. This keyword should not be set if the keywords BYTE, DOUBLE, DT, FIX,
FLOAT, LONG, UL64, or ULONG are used. The default is to return the value(s) as a
string.

ENVI_GET_HEADER_VALUE

ENVI Reference Guide

Chapter 2: ENVI Routines

319

LONG (optional)
Set this keyword to specify that the User_Keyword value(s) be returned as a long
number(s). This keyword should not be set if the keywords BYTE, DOUBLE, DT,
FIX, FLOAT, L64, UL64, or ULONG are used. The default is to return the value(s) as
a string.

UL64 (optional)
Set this keyword to specify that the User_Keyword value(s) be returned as a unsigned
64-bit integer. This keyword should not be set if the keywords BYTE, DOUBLE,
DT, FIX, FLOAT, L64, LONG, or ULONG are used. The default is to return the
value(s) as a string.

ULONG (optional)
Set this keyword to specify that the User_Keyword value(s) be returned as a unsigned
long number(s). This keyword should not be set if the keywords BYTE, DOUBLE,
DT, FIX, FLOAT, LONG, L64, or UL64 are used. The default is to return the value(s)
as a string.

UNDEFINED (optional)
Use this optional keyword to specify a named variable that will be set to one if the
User_Keyword is not present and set to zero if the User_Keyword is present.

Example
The following example will open the image file can_tmr.img using the
ENVI_OPEN_FILE routine. Once the file is open and a valid file ID is returned a
user defined header value for My Scale Factors is stored to the header using
ENVI_ASSIGN_HEADER_VALUE. The change is queried using
ENVI_GET_HEADER_VALUE with the keyword to return floating point values.
The returned result is printed to the ENVI log window. At this point the header
change exists only in the current ENVI session. In order to preserve this change to the
disk file the routine ENVI_WRITE_FILE_HEADER is called to write an updated
header to disk.
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then return
scale_factors = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
envi_assign_header_value, fid=fid, keyword=My Scale Factors, $

ENVI Reference Guide

ENVI_GET_HEADER_VALUE

320

Chapter 2: ENVI Routines


value=scale_factors, precision=3
values = envi_get_header_value(fid, My Scale Factors, /float)
print, My Scale Factors, values
envi_write_file_header, fid

See Also
ENVI_ASSIGN_HEADER_VALUE
ENVI_WRITE_FILE_HEADER

ENVI_GET_HEADER_VALUE

ENVI Reference Guide

Chapter 2: ENVI Routines

321

ENVI_GET_IMAGE
This function returns the display data for the associated display.
ENVI_GET_IMAGE returns either one band, (ns,nl), or three bands, (ns,nl,3).
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = ENVI_GET_IMAGE()

Keywords
BAND_POS
Use this keyword to specify the band position of an RGB image to return. If left
undefined then all three RGB bands are returned. For grayscale images set
BAND_POS equal to zero.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-elements array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

DN
Use this keyword to specify the display number for the data request. Display numbers
can be retrieved in the event handler of user managed display events. Retrieve the
uvalue for ev.top;
widget_control, ev.top, get_uvalue=dn

ENVI Reference Guide

ENVI_GET_IMAGE

322

Chapter 2: ENVI Routines

For user managed display routines just add a menu item to the display.men file,
see Appendix A, Customizing ENVI in the ENVI Users Guide and Modifying the
ENVI Menus in Chapter 4 of the ENVI Programmers Guide for more details.

Example
Retrieve the all the data in the image window. Check to see what type of image is
display and set BAND_POS accordingly.
widget_control, ev.top, get_uvalue=dn
envi_disp_query, dn, xds=xds, yds=yds, color=color
if (color eq 0) then band_pos = 0
data=envi_get_image(dn=dn, band_pos=band_pos, $
dims=[-1, 0, xds[0]-1, 0, yds[0]-1])

See Also
ENVI_DISP_QUERY

ENVI_GET_IMAGE

ENVI Reference Guide

Chapter 2: ENVI Routines

323

ENVI_GET_MAP_INFO
Use this function to get the map information for the specified file or display. The
function returns a map information structure. If there is no map information
associated with the FID or DN, then the UNDEFINED keyword returns a value of 1.

Syntax
Result = ENVI_GET_MAP_INFO()

Keywords
DN (optional)
Use this keyword to specify the display number for the returned projection
information. The function will return the map information structure for the data in the
display. If the displayed data is not georeferenced an Arbitrary projection is returned.

FID (optional)
Use this keyword to specify the file ID for the returned map information. The
function will return the map information structure for the specified file. If the file is
not georeferenced an Arbitrary projection is returned. FID is the value returned from
the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer with
a value greater than zero. An invalid file ID is specified as -1.

UNDEFINED (optional)
Set this keyword to a named variable to contain either 0 or 1. A value of 0 indicates
the returned projection is valid. A value of 1 indicates no projection exists for the
given DN or FID and the resulting map information structure is invalid.

Example
; Select an input file
envi_select, fid=fid
; Get the associated map information structure
map_info = envi_get_map_info(fid=fid)

ENVI Reference Guide

ENVI_GET_MAP_INFO

324

Chapter 2: ENVI Routines

See Also
ENVI_DISP_QUERY
ENVI_FILE_QUERY
ENVI_MAP_INFO_CREATE

ENVI_GET_MAP_INFO

ENVI Reference Guide

Chapter 2: ENVI Routines

325

ENVI_GET_PATH
This routine returns the path where the current version of ENVI is installed.

Syntax
ENVI_GET_PATH()

Arguments
None

Keywords
None

Examples
At the ENVI command line use ENVI_GET_PATH with the PRINT command.
ENVI> print, ENVI_GET_PATH()
C:\RSI\IDL62\products\envi42

To access the path programmatically, you can use something similar to the following:
my_file = filepath(bhtmref.img, root=envi_get_path(), $
subdir=[data])

ENVI Reference Guide

ENVI_GET_PATH

326

Chapter 2: ENVI Routines

ENVI_GET_PROJECTION
Use this function to get the projection information for the specified file, display or
map information handle. The function returns the projection information in the
ENVI_PROJ_STRUCT structure.

Syntax
Result = ENVI_GET_PROJECTION()

Keywords
DN (optional)
Use this keyword to specify the display number for the returned projection
information. The function will return the ENVI_PROJ_STRUCT projection structure
for the data in the display. If the displayed data is not georeferenced an Arbitrary
projection is returned.

FID (optional)
Use this keyword to specify the file ID for the returned projection information. The
function will return the ENVI_PROJ_STRUCT projection structure for the specified
file. If the file is not georeferenced an Arbitrary projection is returned. FID is the
value returned from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is
a long integer with a value greater than zero. An invalid file ID is specified as -1.

PIXEL_SIZE (optional)
Use this keyword to specify a named variable that will contain the X and Y pixel size
of the returned projection. The returned pixel size is a two element double precision
array. The first element is the X pixel size and the second element is the Y pixel size.

UNITS (optional)
Use this keyword to specify a named variable that will contain the projection units.
This is the integer units value and can be transformed to the string units name using
the procedure ENVI_TRANSLATE_PROJECTION_UNITS.

ENVI_GET_PROJECTION

ENVI Reference Guide

Chapter 2: ENVI Routines

327

Example
PRO atest
; Select a file
ENVI_SELECT, FID = fid
IF (fid EQ -1) THEN RETURN
; Get the projection information
proj = ENVI_GET_PROJECTION(FID = fid)
PRINT, proj
END

See Also
ENVI_PROJ_CREATE

ENVI Reference Guide

ENVI_GET_PROJECTION

328

Chapter 2: ENVI Routines

ENVI_GET_RGB_TRIPLETS
Use this procedure to get the RGB triplets associated with a graphics color index.
Note
An interactive ENVI session is required to run this routine.

Syntax
ENVI_GET_RGB_TRIPLETS, Index, R, G, B

Arguments
Index
Index is the graphics color index for the desired triplet. The modulo operator using
the total number of graphics colors is applied to Index prior accessing the color
triplets.

R
R is the red color value.

G
G is the red color value.

B
B is the red color value.

Example
pro example_envi_get_rgb_triplets
;
; Save the RGB values for 5
; graphics colors into the
; array lookup
;
lookup = bytarr(3,5)
;
for i=0L,4 do begin
envi_get_rgb_triplets, i+2, r, g, b

ENVI_GET_RGB_TRIPLETS

ENVI Reference Guide

Chapter 2: ENVI Routines

329

lookup[0,i] = [r,g,b]
endfor
;
; Print the resulting array
; lookup
;
print, lookup
end

ENVI Reference Guide

ENVI_GET_RGB_TRIPLETS

330

Chapter 2: ENVI Routines

ENVI_GET_ROI
This function is used to get the address of each point in a Region of Interest (ROI).
ENVI_GET_ROI returns the ROI pointers associated with the input ID. ROI
addresses are a one dimensional spatial address. The address of a ROI pixel at
(r_sample, r_line) would be calculated as, r_sample + r_line * ns.

Syntax
Result = ENVI_GET_ROI(ROI_Id)

Arguments
ROI_Id
ROI_Id is a single ID returned from the function ENVI_GET_ROI_IDS.

Keywords
ROI_COLOR
Use this keyword to specify a named variable that will contain the RGB color value
for the ROI_Id. ROI_COLORS is byte array of size three.

ROI_NAME
Use this keyword to specify a named variable that will contain the ROI name.
ROI_NAME is a string.

Example
Use ENVI_GET_ROI to get the address and name of each region of interest
associated with display DN. Then print out the ROI name and number of points.
roi_ids = envi_get_roi_ids(dn=dn)
for i=0, n_elements(roi_ids)-1 do begin
roi_addr = envi_get_roi(roi_ids[i], roi_name=name)
print, ROI: , name, n_elements(roi_addr)
endfor

ENVI_GET_ROI

ENVI Reference Guide

Chapter 2: ENVI Routines

331

See Also
ENVI_CREATE_ROI
ENVI_DEFINE_ROI
ENVI_GET_ROI_DATA
ENVI_GET_ROI_DIMS_PTR
ENVI_GET_ROI_IDS
ENVI_RESTORE_ROIS
ENVI_SAVE_ROIS

ENVI Reference Guide

ENVI_GET_ROI

332

Chapter 2: ENVI Routines

ENVI_GET_ROI_DATA
This function is used to get the data associated with a roi address.

Syntax
Result = ENVI_GET_ROI_DATA(ROI_Id)

Arguments
ROI_Id
ROI_Id is a single ID returned from the function ENVI_GET_ROI_IDS.

Keywords
ADDR (optional)
Use this keyword to specify the addresses of each ROI data value returned. The ROI
addresses are returned from the routine ENVI_GET_ROI. The returned data values
match the corresponding input address.

FID
Use this keyword to specify the file ID for the open file. This is the value returned by
the R_FID keyword to the ENVI_OPEN_FILE procedure. FID is a long integer with
a value greater than zero. An invalid file ID is specified as -1.

POS
Use this keyword to specify the band position(s) to get ROI data for. If POS is a
single element the result is Result(npts) otherwise the result is
Result(n_elements(pos), npts).

Example
Use ENVI_GET_ROI_DATA to get the data values for bands zero, one and two.
data = envi_get_roi_data(roi_id[0], fid=fid, pos=[0,1,2])

ENVI_GET_ROI_DATA

ENVI Reference Guide

Chapter 2: ENVI Routines

333

Notes
If you have a large ROI and many bands in the POS array then the memory
requirements may exceed the capacity of your machine. One way to break up the
problem is to request fewer band in the POS array, processes the data, and then get
the ROI for the next set of bands. To minimize memory usage only request one band
at a time and then loop on the number of bands.
The order of ROI locations within the returned array ADDR can be different for the
case where ENVI_GET_ROI_DATA ( ) is called with POS set to more than one
band. ADDR will match the order of the data in the returned array in either case (i.e.
DATA[0] will have come from location ADDR[0]). But the order of ADDR can be
different for each case (i.e. dont expect that ADDR1 will match ADDR2 for the two
calls to ENVI_GET_ROI_DATA ( ) where the first case uses POS= [0], and the
second case uses POS= [0,1,2]).

See Also
ENVI_CREATE_ROI
ENVI_DEFINE_ROI
ENVI_GET_ROI_DIMS_PTR
ENVI_GET_ROI_IDS
ENVI_RESTORE_ROIS
ENVI_SAVE_ROIS

ENVI Reference Guide

ENVI_GET_ROI_DATA

334

Chapter 2: ENVI Routines

ENVI_GET_ROI_DIMS_PTR
This function is used to get the DIMS Region of Interest (ROI) pointer value.
ENVI_GET_ROI_DIMS_PTR returns the value used in DIMS[0]. Since ROI pointer
values are likely to change as ROIs are created, update or removed. The user should
always use the ROI_ID to get the current ROI pointer value.

Syntax
Result = ENVI_GET_ROI_DIMS_PTR(ROI_Id)

Arguments
ROI_Id
ROI_Id is a single ID returned from the function ENVI_GET_ROI_IDS.

Example
Set the first element of the DIMS array using ROI_ID(0). To get the Nth DIMS
pointer then just use ROI_ID(N).
roi_ids = envi_get_roi_ids(fid = fid)
dims = [envi_get_roi_dims_ptr(roi_ids[0]), 0, 0, 0, 0]

See Also
ENVI_CREATE_ROI
ENVI_DEFINE_ROI
ENVI_GET_ROI
ENVI_GET_ROI_DATA
ENVI_GET_ROI_IDS
ENVI_RESTORE_ROIS
ENVI_SAVE_ROIS

ENVI_GET_ROI_DIMS_PTR

ENVI Reference Guide

Chapter 2: ENVI Routines

335

ENVI_GET_ROI_IDS
This function returns the Region of Interest (ROI) IDs associated with a display, a file
or a spatial size (ns,nl). ENVI_GET_ROI_IDS returns an array of ROI IDs.

Syntax
Result = ENVI_GET_ROI_IDS()

Keywords
DN (optional)
Use this optional keyword to specify the display number associated with the desired
ROIs. Display numbers can be retrieved in the event handler of user managed display
events. Retrieve the uvalue for ev.top:
widget_control, ev.top, get_uvalue=dn.

For user managed display routines just add a menu item to the display.men file,
see Modifying the ENVI Menus in Chapter 4 of the ENVI Programmers Guide for
more details.

FID (optional)
Use this optional keyword to specify the file ID associated with the desired ROIs.
This is the value returned by the R_FID keyword to the ENVI_OPEN_FILE
procedure. FID is a long integer with a value greater than zero. An invalid file ID is
specified as -1.

NL (optional)
Use this optional keyword to specify the number of image lines associated with the
desired ROIs. If NL is specified then NS must be specified.

NS (optional)
Use this optional keyword to specify the number of image samples associated with
the desired ROIs. If NS is specified then NL must be specified.

ROI_COLORS (optional)
Use this optional keyword to specify a named variable that will contain the RGB
color value for each ROI ID. ROI_COLORS is byte array of size (3, # ROI IDs).
ENVI Reference Guide

ENVI_GET_ROI_IDS

336

Chapter 2: ENVI Routines

ROI_NAMES (optional)
Use this optional keyword to specify a named variable that will contain a string array
of ROI names for each ROI ID. The default name includes the ROI name, ROI color,
and number of points. Set the keyword SHORT_NAME or LONG_NAME to modify
the default ROI_NAMES.

SHORT_NAME (optional)
Set this optional keyword to return only the ROI name in the variable specified by
ROI_NAMES. This keyword cannot be set if LONG_NAME is set.

LONG_NAME (optional)
Set this keyword to return the ROI name, ROI color, number of point and associated
image size in the variable specified by ROI_NAMES. This keyword cannot be set if
SHORT_NAME is set.

Example
Get the ROI IDs associated with a display. When a routine is called from the display
menu the uvalue of ev.top contains the display number.
widget_control, ev.top, get_uvalue=dn
roi_ids = envi_get_roi_ids(dn=dn, roi_names=roi_names, $
roi_colors=roi_colors)

See Also
ENVI_CREATE_ROI
ENVI_DEFINE_ROI
ENVI_GET_ROI
ENVI_GET_ROI_DATA
ENVI_GET_ROI_DIMS_PTR
ENVI_GET_ROI_INFORMATION
ENVI_RESTORE_ROIS
ENVI_SAVE_ROIS

ENVI_GET_ROI_IDS

ENVI Reference Guide

Chapter 2: ENVI Routines

337

ENVI_GET_ROI_INFORMATION
The ENVI_GET_ROI_INFORMATION procedure retrieves information associated
with defined ROIs.

Syntax
ENVI_GET_ROI_INFORMATION, ROI_IDS
[, /LONG_NAME | , /SHORT_NAME ] [, NL=variable] [, NPTS=variable]
[, NS=variable] [, ROI_COLORS=variable] [, ROI_NAMES=variable]

Arguments
ROI_IDS
The IDs of defined ROIs on which to get information. ROI_IDS is returned from the
function ENVI_GET_ROI_IDS.

Keywords
LONG_NAME (optional)
Set this optional keyword to return the long version of the ROI name (containing ROI
color, number of points and associated image size) in the variable specified by
ROI_NAMES. This keyword cannot be set if SHORT_NAME is set.

NL (optional)
Use the optional NL keyword to specify a named variable to contain the number of
lines associated with each ROI ID.

NPTS (optional)
Use the optional NPTS keyword to specify a named variable to contain the number of
points associated with each ROI ID.

NS (optional)
Use the optional NS keyword to specify a named variable to contain the number of
samples associated with each ROI ID.

ENVI Reference Guide

ENVI_GET_ROI_INFORMATION

338

Chapter 2: ENVI Routines

ROI_COLORS (optional)
Use this optional keyword to specify a named variable to contain the RGB color
value for each ROI ID. ROI_COLORS is a byte array of size (3, # ROI IDs).

ROI_NAMES (optional)
Use this optional keyword to specify a named variable to contain a string array of
ROI names for each ROI ID. The default name includes the ROI name, ROI color,
and number of points. Set the keyword SHORT_NAME or LONG_NAME to modify
the default ROI_NAMES.

SHORT_NAME (optional)
Set this optional keyword to return only the ROI name in the variable specified by
ROI_NAMES. This keyword cannot be set if LONG_NAME is set.

See Also
ENVI_CREATE_ROI
ENVI_DEFINE_ROI
ENVI_GET_ROI
ENVI_GET_ROI_DATA
ENVI_GET_ROI_DIMS_PTR
ENVI_GET_ROI_IDS
ENVI_RESTORE_ROIS
ENVI_SAVE_ROIS

ENVI_GET_ROI_INFORMATION

ENVI Reference Guide

Chapter 2: ENVI Routines

339

ENVI_GET_SLICE
This function returns the requested spectral slice of data. The spectral slices can be
returned in either BIP or BIL storage order.

Syntax
Result = ENVI_GET_SLICE()

Keywords
BIL
Set this keyword to specify that the data should be returned in BIL format.

BIP
Set this keyword to specify that the data should be returned in BIP format.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

LINE
Use this keyword to specify the line number to extract the slice from. LINE is a zero
based line number.

XE
Use this keyword to specify the X ending value. XE is a zero based number.

XS
Use this keyword to specify the X starting value. XS is a zero based number.

ENVI Reference Guide

ENVI_GET_SLICE

340

Chapter 2: ENVI Routines

Example
Return line 20 (zero based count), pixels 20 through 40, bands 1 and 3.
data = envi_get_slice(fid=fid, line=20, pos=[1,3], $
xs=20, xe=40)

ENVI_GET_SLICE

ENVI Reference Guide

Chapter 2: ENVI Routines

341

ENVI_GET_STATISTICS
This procedure is used to read data from an ENVI statistics (.sta) file. The values
from the statistics file are returned by the keyword arguments. The value of POS and
CPOS, depending on the statistics retrieved, indicate which bands have valid
statistics values.
Note
The existence of a statistics file does not guarantee that statistics are computed for
all bands, always check POS and CPOS. In fact a NULL statistics file may exists
where POS=-1 and CPOS=-1.

Syntax
ENVI_GET_STATISTICS, STA_Name

Arguments
STA_name
STA_Name is the filename of an ENVI statistics (.sta) file.

Keywords
COV
Set this keyword to specify a named variable that will contain the covariance for the
image. If COV is undefined the covariance was not calculated. COV is a (nb,nb)
array where nb is defined by CPOS

CPOS
Set this keyword to specify a named variable that will contain the array of band
indexes used to calculate COV, EVAL and EVEC. The value of CPOS can even be
[-1] in which case COV, EVAL and EVEC are not valid.

DMAX
Set this keyword to specify a named variable that will contain the image maximums.
If DMAX is undefined the basic statistics were not calculated. DMAX is a (nb) array
where nb is defined by POS

ENVI Reference Guide

ENVI_GET_STATISTICS

342

Chapter 2: ENVI Routines

DMIN
Set this keyword to specify a named variable that will contain the image minimum. If
DMIN is undefined the basic statistics were not calculated. DMIN is a (nb) array
where nb is defined by POS

EVAL
Set this keyword to specify a named variable that will contain the eigen values for the
image. If EVAL is undefined the eigen values was not calculated. EVAL is a (nb,nb)
array where nb is defined by CPOS

EVEC
Set this keyword to specify a named variable that will contain the eigen vectors for
the image. If EVEC is undefined the eigen vectors were not calculated. EVEC is a
(nb,nb) array where nb is defined by CPOS

MEAN
Set this keyword to specify a named variable that will contain the image mean. If
MEAN is undefined the basic statistics were not calculated. MEAN is a (nb) array
where nb is defined by POS

POS
Set this keyword to specify a named variable that will contain the array of band
indexes used to calculate basic statistics, DMIN, DMAX, MEAN and STD. The
value of POS can even be [-1] in which case DMIN, DMAX, MEAN and STD are
not valid.

STDV
Set this keyword to specify a named variable that will contain the image standard
deviation. If STDV is undefined the basic statistics were not calculated. STDV is a
(nb) array where nb is defined by POS

ENVI_GET_STATISTICS

ENVI Reference Guide

Chapter 2: ENVI Routines

343

Example
This example get the statistics from the file myimage.sta and prints out the
minimum, maximum and mean for each band statistics was computed on.
envi_get_statistics, /data/myimage.sta, mean=mean, $
dmax=dmax, dmin=dmin, pos=pos
if (pos[0] eq -1) then return
for i=0, n_elements(pos)-1 do $
print, Band , pos[i], dmin[i], dmax[i], mean[i]

ENVI Reference Guide

ENVI_GET_STATISTICS

344

Chapter 2: ENVI Routines

ENVI_GET_TILE
This function returns the requested tile data. Tiles may be requested multiple times
and in any order between the ENVI_INIT_TILE and the ENVI_TILE_DONE calls.

Syntax
Result = ENVI_GET_TILE(Tile_id, Cur_tile)

Arguments
Tile_id
The tile id returned from ENVI_INIT_TILE

Cur_tile
The tile number for the requested tile. This number must fall between zero and the
number of tiles -1.

Keywords
BAND_INDEX
If the file in use is in BSQ tile interleave format, use this keyword to specify a named
variable that will contain the index to the current band.

YE
Use this keyword to specify a named variable that will contain the ending Y value for
the current tile, in file coordinates.

YS
Use this keyword to specify a named variable that will contain the starting Y value
for the current tile, in file coordinates. For spatially subsetted images, the first YS is
equal to the first line in the subset image, which is not necessarily line zero.

ENVI_GET_TILE

ENVI Reference Guide

Chapter 2: ENVI Routines

345

Example
This example illustrates the tile processing loop.
for i=0, num_tiles-1 do begin
tile_data=envi_get_tile(tile_id, i, ys=ys)
.

tile processing commands here


endfor

Notes
When trying to determine the output line number make sure to subtract the spatial
subset index dims[3] from the returned YS:
ys_memory = ys-dims[3]

See Also
ENVI_INIT_TILE
ENVI_TILE_DONE

ENVI Reference Guide

ENVI_GET_TILE

346

Chapter 2: ENVI Routines

ENVI_GLT_DOIT
The ENVI_GLT_DOIT procedure builds a Geographic Lookup Table (GLT) file for
the corresponding x and y map location images. The x and y map location images and
the associated map projection are used to build the GLT file in the specified output
projection. Additionally, the user can specify a rotation for the output GLT image.
GLT images are then correspondingly used to georeference additional images.

Syntax
ENVI_DOIT, ENVI_GLT_DOIT, DIMS=array, I_PROJ= structure,
O_PROJ=structure, /IN_MEMORY | OUT_NAME=string, PIXEL_SIZE=value
[, R_FID=fileID] [, ROTATION=value] [, /SUPER]
, X_FID=fileID, X_POS=array, Y_FID=fileID, Y_POS=array

Arguments
None

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]:Unused for this function, set to -1.

DIMS[1]:The starting X pixel. (The first pixel is number zero.)

DIMS[2]:The ending X pixel.

DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

DIMS[4]:The ending Y pixel.

I_PROJ
Use this keyword to specify the input projection for the x and y map location images.
Both x and y must be in the same projection. I_PROJ cannot be set to the Arbitrary
projection. I_PROJ is a projection structure returned from ENVI_PROJ_CREATE or
ENVI_GET_PROJECTION.

ENVI_GLT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

347

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk. This keyword is ignored if the SUPER
keyword is set.

O_PROJ
Use this keyword to specify the output projection for the GLT file. O_PROJ cannot
be set to the Arbitrary projection. O_PROJ is a projection structure returned from
ENVI_GET_PROJECTION or ENVI_PROJ_CREATE.

OUT_NAME
Use this keyword to specify an output file name for the resulting data.

PIXEL_SIZE
Set this keyword to a scalar value that represents the pixel size (both the x and y) of
the output GLT image. The x and y pixel size of output GLT image are individually
set to this scalar value. The default value is calculated from the pixel size of the input
projection.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

ROTATION
Set this keyword to specify the rotation of the GLT image in the defined output
projection. Rotation is expressed in degrees clockwise from North. The default is to
calculate the rotation of the input x and y map location images. To set the GLT output
image to North up set rotation to zero.

SUPER (optional)
Set this keyword to specify the output of a Super GLT file. If this keyword is set, then
OUT_NAME must be specified (the IN_MEMORY keyword is ignored).

X_FID
Use this keyword to specify the file ID for the x map projection values file. This is the
value returned from the keyword R_FID in the ENVI_OPEN_FILE procedure.

ENVI Reference Guide

ENVI_GLT_DOIT

348

Chapter 2: ENVI Routines

X_FID is a long integer with a value greater than zero. An invalid file ID is specified
as -1.

X_POS
Use this keyword to specify the band position of the x map projection values. X_POS
is an array of long integers, ranging from zero to the number of bands-1.

Y_FID
Use this keyword to specify the file ID for the y map projection values file. This is the
value returned from the keyword R_FID in the ENVI_OPEN_FILE procedure.
Y_FID is a long integer with a value greater than zero. An invalid file ID is specified
as -1.

Y_POS
Use this keyword to specify the band position of the y map projection values. Y_POS
is an array of long integers, ranging from zero to the number of bands-1.

See Also
ENVI_GEOREF_FROM_GLT_DOIT
ENVI_REGISTER_DOIT

ENVI_GLT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

349

ENVI_GRID_DOIT
Use this program to convert a set of irregularly gridded XYZ points to a raster image.

Syntax
ENVI_DOIT, ENVI_GRID_DOIT

Keywords
EXTRAP (optional)
Set this keyword to allow extrapolation to the outer edge of the image. Otherwise the
image is defined by the bounding polygon around the exterior points and all other
points are set to zero.

I_PROJ (optional)
Use this keyword to specify the input map projection structure for the irregularly
gridded arrays of points, X_PTS and Y_PTS. I_PROJ is a structure of type
{envi_proj_struct}, ENVI projection structures are defined in greater detail in
Appendix D, ENVI Map Projections in the ENVI Users Guide.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

INTERP
Set this keyword to specify the type of interpolation. INTERP is set to one of the
following:

0 Linear interpolation

1 Quintic interpolation

O_PROJ
Use this keyword to specify the output map projection structure for the gridded
points. The points are automatically converted from the input projection to the output
projection. O_PROJ is a structure of type {envi_proj_struct}, ENVI projection
structures are defined in greater detail in Appendix D, ENVI Map Projectionsin the
ENVI Users Guide.
ENVI Reference Guide

ENVI_GRID_DOIT

350

Chapter 2: ENVI Routines

OUT_DT
Use this keyword to specify the output file data type. OUT_DT should be an integer
value matching one of the standard data types: 1-byte, 2-integer, 3-long, 4-float, 5double 6-complex.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

PIXEL_SIZE
Use this keyword to specify the pixel size of output image. PIXEL_SIZE is a floating
point array of two specifying the X and Y pixel size respectively.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

XMAX (optional)
Use this keyword to specify the maximum X value to use. The default is to use the
maximum of the X_PTS array.

XMIN (optional)
Use this keyword to specify the minimum X value to use. The default is to use the
minimum of the X_PTS array.

X_PTS
Use this keyword to specify a corresponding array of irregularly gridded X points.
The number of elements of X_PTS, Y_PTS, and Z_PTS must be equal.

YMAX (optional)
Use this keyword to specify the maximum Y value to use. The default is to use the
maximum of the Y_PTS array.

ENVI_GRID_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

351

YMIN (optional)
Use this keyword to specify the minimumY value to use. The default is to use the
minimum of the Y_PTS array.

Y_PTS
Use this keyword to specify a corresponding array of irregularly gridded Y points.
The number of elements of X_PTS, Y_PTS, and Z_PTS must be equal.

Z_PTS
Use this keyword to specify a corresponding array of irregularly gridded Z points.
The number of elements of X_PTS, Y_PTS, and Z_PTS must be equal.

Example
forward_function envi_proj_create
pro example_envi_grid_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the necessary variables
;
x_pts = [0, 500, 500,
0, 250]
y_pts = [0,
0, 500, 500, 250]
z_pts = [0, 100, 200, 300, 1000]
o_proj = envi_proj_create(/arbitrary)
pixel_size = [1.,1.]
out_name =testimg
;
; Call the doit
;
envi_doit, envi_grid_doit, $
x_pts=x_pts, y_pts=y_pts, $
z_pts=z_pts, out_dt=2, $
pixel_size=pixel_size, $
o_proj=o_proj, extrap=1, $
out_name=out_name, interp=1, $

ENVI Reference Guide

ENVI_GRID_DOIT

352

Chapter 2: ENVI Routines


r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI_GRID_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

353

ENVI_GS_SHARPEN_DOIT
The ENVI_GS_SHARPEN_DOIT procedure computes the Gram-Schmidt spectral
sharpening. This routine is used to sharpen a low spatial resolution multi-band image
using associated high resolution panchromatic bands. The low spatial resolution
panchromatic band can either be specified by the user or calculated from the low
spatial resolution multi-band image.

Syntax
ENVI_DOIT, ENVI_GS_SHARPEN_DOIT, DIMS=array, FID=fileID
[, HIRES_DIMS=array], HIRES_FID=fileID, HIRES_POS=array,
/IN_MEMORY | OUT_NAME=string [, INTERP={0 | 1 | 2}]
[, LORES_DIMS=array] [, LORES_FID=fileID] [, LORES_POS=array]
[, M_FID=fileID] [, M_POS=array] [, MASK_VALUE=value],
METHOD={0 | 1} [, OUT_BNAME=string array], POS=array [, R_FID=fileID]

Arguments
None

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]:Unused for this function, set to -1.

DIMS[1]:The starting X pixel. (The first pixel is number zero.)

DIMS[2]:The ending X pixel.

DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

DIMS[4]:The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.
ENVI Reference Guide

ENVI_GS_SHARPEN_DOIT

354

Chapter 2: ENVI Routines

FILTER_FID (optional)
Use this optional keyword to specify a named variable representing the filter file ID
to be used with METHOD values 2 or 3. The filter file is in the form of a spectral
library and contains the spectral response functions for the bands in a multispectral
image. This file is only needed if the functions do not already exist in ENVI.

FILTER_POS (optional)
Use this optional keyword to specify a scalar representing the index
(position/location) of the filter function in the specified spectral library. If
FILTER_POS is not specified, the default is 0 and the first filter function in the
library is used.

HIRES_DIMS (optional)
Use this optional keyword to specify the spatial dimensions of the high spatial
resolution panchromatic band. HIRES_DIMS is a five-element array of long integers
with the following definitions:

HIRES_DIMS[0]:Unused for this function, set to -1.

HIRES_DIMS[1]:The starting X pixel. (The first pixel is number zero.)

HIRES_DIMS[2]:The ending X pixel.

HIRES_DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

HIRES_DIMS[4]:The ending Y pixel.

HIRES_FID
Use this keyword to specify the file ID for the high spatial resolution panchromatic
file. This is the value returned from the keyword R_FID in the ENVI_OPEN_FILE
procedure. HIRES_FID is a long integer with a value greater than zero. An invalid
file ID is specified as -1.

HIRES_POS
Use this keyword to specify the band position of the high spatial resolution
panchromatic band. HIRES_POS is an array of long integers, ranging from zero to
the number of bands-1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.
ENVI_GS_SHARPEN_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

355

INTERP (optional)
Set this keyword equal to one of the following values to specify the resampling
method:

0 = Nearest Neighbor

1 = Bilinear Interpolation

2 = Cubic Convolution

The low spatial resolution images are resampled to the high resolution space using
the specified resampling method. The default is Nearest Neighbor.

LORES_DIMS (optional)
Use this keyword to specify the spatial dimensions of the low spatial resolution
panchromatic band. LORES_DIMS must be specified if METHOD is equal to one.
LORES_DIMS is a five-element array of long integers with the following
definitions:

LORES_DIMS[0]:Unused for this function, set to -1.

LORES_DIMS[1]:The starting X pixel. (The first pixel is number zero.)

LORES_DIMS[2]:The ending X pixel.

LORES_DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

LORES_DIMS[4]:The ending Y pixel.

LORES_FID (optional)
Use this keyword to specify the file ID for the low spatial resolution panchromatic
file. LORES_FID must be specified if METHOD is equal to one. This is the value
returned from the keyword R_FID in the ENVI_OPEN_FILE routine. LORES_FID
is a long integer with a value greater than zero. An invalid file ID is specified as -1.

LORES_POS (optional)
Use this keyword to specify the band position of the low spatial resolution
panchromatic band. LORES_POS must be specified if METHOD is equal to one.
LORES_POS is an array of long integers, ranging from 0 to the number of bands-1.

ENVI Reference Guide

ENVI_GS_SHARPEN_DOIT

356

Chapter 2: ENVI Routines

M_FID (optional)
Use this keyword to specify the file ID for the mask file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

M_POS (optional)
Use this keyword to specify the band position of the mask band. M_POS is a single
long value greater than or equal to zero.

MASK_VALUE (optional)
Use this keyword to specify the output value for the masked pixels. MASK_VALUE
is only used when M_FID and M_POS are specified. The default for MASK_VALUE
is zero.

METHOD
Use this keyword to specify the method for low spatial resolution panchromatic band.
METHOD is an integer number with one of the following values:

0 = Average over all bands specified by POS to form the low spatial resolution
panchromatic band

1 = Use the low spatial resolution panchromatic band specified by


LORES_FID, LORES_DIMS, LORES_POS

2 = Create low-resolution pan using high-resolution pan filter function. If this


value is specified, the F_FID keyword must be used

3 = Create low-resolution pan using user-defined filter function. If this value is


specified, the F_FID keyword must be used

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

ENVI_GS_SHARPEN_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

357

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

See Also
ENVI_PC_SHARPEN_DOIT
SHARPEN_DOIT

ENVI Reference Guide

ENVI_GS_SHARPEN_DOIT

358

Chapter 2: ENVI Routines

ENVI_INFO_WID
Use this procedure to display an ENVI report widget. The contents of the string
argument are displayed in a text widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
ENVI_INFO_WID, Str

Arguments
Str
An array of strings to display in the text widget. Each element in the string array is
displayed on a separate line.

Keywords
TITLE
Set this optional keyword to specify the title of the report widget.

XS
Use this optional keyword to specify the number of columns in the text widget.

YS
Use this optional keyword to specify the number of rows in the text widget.

Example
This example displays three lines of text with one blank line in a report widget.
str = [Line 1, Next line is blank, , Line 4]
envi_info_wid, str, title=Report

ENVI_INFO_WID

ENVI Reference Guide

Chapter 2: ENVI Routines

359

ENVI_INIT_TILE
This function is used to initialize processing of tile data. The returned value is the tile
ID used to access the data.

Syntax
Result = ENVI_INIT_TILE(Fid, Pos)

Arguments
Fid
The file id of the file to process.

Pos
The array of band positions to process.

Keywords
COMPLEX
Set this keyword to return the output data as complex.

INTERLEAVE
Use this keyword to specify the type of tile interleaving to perform. The default is to
perform the same type of interleave as the file. Set this keyword equal to zero if the
tile is in BSQ format, to one if it is in BIL format, or to two if it is in BIP format.

MATCH_ID
Set this keyword equal to the tile ID of a previously initialized piece of tile data in
order to match the tile size of the current data to the size of the previously initialized
data. This is used to get consistent tiles for multiple tile requests.

NUM_TILES
Use this keyword to specify a named variable that will contain the number of tiles in
the request.

ENVI Reference Guide

ENVI_INIT_TILE

360

Chapter 2: ENVI Routines

OVERLAP
Use this keyword to specify the pixel overlap wanted for each spatial tile. OVERLAP
is only used for INTERLEAVE of zero.

TILE_SCALE
Use this keyword to adjust the size of the default spatial tile size in ENVI. A value of
2 will cause the size in bytes of a spatial tile to be half as large. A value of 4 will
cause the size in bytes of the spatial tile to be a quarter as large.
This keyword overrides the Image Tile Size preference.

XE
Use this keyword to specify the X ending index. The default is the last sample.

XS
Use this keyword to specify the X starting index. The default is the first sample.

YE
Use this keyword to specify the Y ending index. The default is the last line.

YS
Use this keyword to specify the Y starting index. The default is the first line.

Example
This example initializes the file processing for FID and the bands in array POS. The
value of NUM_TILES is now the total loop count for processes all the tiles.
tile_id=envi_init_tile(fid, pos, num_tiles=num_tiles)

Notes
ENVI_INIT_TILE must be performed prior to requests for tiled data.

See Also
ENVI_GET_TILE
ENVI_TILE_DONE

ENVI_INIT_TILE

ENVI Reference Guide

Chapter 2: ENVI Routines

361

ENVI_IO_ERROR
Use this procedure to report Input/Output processing errors.

Syntax
ENVI_IO_ERROR, Proc

Arguments
Proc
A text string to be echoed to the terminal when an I/O error occurs. Generally, Proc
should be the name of the procedure in which ENVI_IO_ERROR is called.

Keywords
UNIT (optional)
Use this optional keyword to specify the unit number of the output file being
generated. If UNIT is specified and an error occurs, ENVI_IO_ERROR will delete
this file.

Example
The following example shows how to display an IO error when MY_ERROR is not
equal to zero.
if (my_error ne 0) then $
envi_io_error, An error occurred in my processing.

ENVI Reference Guide

ENVI_IO_ERROR

362

Chapter 2: ENVI Routines

ENVI_L7_CPF
The ENVI_L7_CPF procedure retrieves Landsat 7 calibration parameters from the
RSI web server. The RSI web server is an interface to the Landsat 7 CPF and
Metadata files provided by EROS Data Center.

Syntax
ENVI_L7_CPF, SName [, BIAS=variable] [, ERROR=variable] [, GAIN=variable]
[, /LOW] [, SUN_ANGLE=variable]

Arguments
SName
The short name of the file to be used for the parameters. The short name is returned
from a call to ENVI_FILE_QUERY. This must follow the Landsat 7 file naming
convention of L7fppprrr_rrrYYYYMMDD_AAA.XXX, defined as follows.

ENVI_L7_CPF

L7

Indicates a Landsat-7 mission.

Indicates the ETM+ data format.

ppp

Indicates the starting path of the product.

rrr_rrr

Indicates the starting and ending rows of the


product.

YYYYMMDD

Indicates the acquisition date (year, month, day) of


an image.

ENVI Reference Guide

Chapter 2: ENVI Routines


AAA

363

Indicates the Band number:


B10 = band 1
B20 = band 2
B30 = band 3
B40 = band 4
B50 = band 5
B61 = band 6L (low gain)
B62 = band 6H (high gain)
B70 = band 7
B80 = band 8

XXX

Indicates the file type (.TIF or .HDF).

Keywords
BIAS (optional)
Use the optional BIAS keyword to specify a named variable to contain the returned
bias.

ERROR (optional)
Use the optional ERROR keyword to specify a named variable to contain the error
status. A value of 0 indicates no error occurred, and a value of 1 indicates an error
occurred during processing.

GAIN (optional)
Use the optional GAIN keyword to specify a named variable to contain the returned
gain.

LOW (optional)
Some of the earlier CPF files do not contain an H or L value for the gain of the
specified band. Set the LOW keyword to return the low gain if neither a low or high
gain are specified in the database. The high gain is returned by default.

SUN_ANGLE (optional)
Use the optional SUN_ANGLE keyword to specify a named variable to contain the
returned Sun elevation angle.
ENVI Reference Guide

ENVI_L7_CPF

364

Chapter 2: ENVI Routines

ENVI_LAYER_STACKING_DOIT
Use this processing routine to build a new multiband file from georeferenced images
of various pixel sizes, extents, and projections. The input bands will be resampled
and reprojected to a common output projection and pixel size. The output file will
contain only data based on the map extent of the input images. The user can select
either an inclusive (encompass all the files) or exclusive (encompass file overlap)
output image.

Syntax
ENVI_DOIT, ENVI_LAYER_STACKING_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the operation
for each input file. DIMS is an array of long integers, [5, number of bands], with the
following definitions:

DIMS[0,i]: Unused for this function, set to -1.

DIMS[1,i]: The starting X pixel for the ith band. (The first pixel is number
zero.)

DIMS[2,i]: The ending X pixel for the ith band.

DIMS[3,i]: The starting Y pixel for the ith band. (The first pixel is number
zero.)

DIMS[4,i]: The ending Y pixel for the ith band.

EXCLUSIVE (optional)
Set this optional keyword to specify an exclusive range, encompassing file overlap,
based on the map extent of each input layer. The default is an inclusive range,
encompassing all files. The spatial size of a layer stacked image generated with the
EXCLUSIVE keyword set will always be equal to or smaller than the inclusive
result.

ENVI_LAYER_STACKING_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

365

FID
Use this keyword to specify the file IDs for the input files. FID is an array of input
file IDs with one file ID for each input file (layer). This is the value returned from the
keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer with a
value greater than zero. An invalid file ID is specified as -1. The number of elements
of POS and FID correspond to the number of input files to stack together, one entry
for each file.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers with one entry for
each input file. The values of POS range from zero to the number of bands-1 of each
input file. The number of elements of POS and FID correspond to the number of
input files to stack together, one entry for each file.

IN_MEMORY (optional)
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk and OUT_NAME must be specified. If
IN_MEMORY is set then OUT_NAME is not used.

INTERP (optional)
Set this keyword equal to one of the following values to specify the resampling
method:

0 Nearest Neighbor

1 Bilinear

2 Cubic Convolution

The default is to use Nearest Neighbor, method zero.

OUT_BNAME (optional)
Use this optional keyword to specify a string array of output band names.

OUT_DT
Set this keyword to specify the IDL data type of the output file, using the following
IDL convention:

1 byte (8-bits)

ENVI Reference Guide

ENVI_LAYER_STACKING_DOIT

366

Chapter 2: ENVI Routines

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. OUT_NAME
is a string variable specifying the filename and path of the output file.

OUT_PROJ
Use this keyword to specify the output projection for the layer stacked file.
OUT_PROJ is a projection structure returned from ENVI_GET_PROJECTION or
ENVI_PROJ_CREATE.

OUT_PS
Use this keyword to specify the output X and Y pixel size. OUT_PS is a two-element
double precision array of the output X and Y pixel sizes, respectively. OUT_PS is in
the same units as specified in OUT_PROJ.

R_FID (optional)
Use this optional keyword to specify a named variable that will contain the file ID for
the processed data. This file ID can be used to access the processed data. An invalid
file ID is specified as -1.

Example
The following example is used to layer stack the Bighorn TM and DEM images
together. This example uses the following files found in the DATA directory of the
ENVI installation:

ENVI_LAYER_STACKING_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

bhtmref.img

bhtmref.hdr

367

and the following files found in the bh_3d directory of the ENVI Data CD #1:

bhdemsub.img

bhdemsub.hdr

The example will use an inclusive range, encompassing all the files, with cubic
convolution resampling. Each of the six TM bands and the single DEM band will be
output into a new layer stacked image with the projection of the TM data.
forward_function envi_get_projection
pro example_envi_layer_stacking_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the first input file.
; We will also open the one band
; dem file to layer stack with
; this file.
;
envi_open_file, bhtmref.img, r_fid=t_fid
if (t_fid eq -1) then begin
envi_batch_exit
return
endif
;
; Open the second input file.
;
envi_open_file, bhdemsub.img, r_fid=d_fid
if (d_fid eq -1) then begin
envi_batch_exit
return
endif
;
; Use all the bands from both files
; and all spatial pixels. First build the
; array of FID, POS and DIMS for both
; files.

ENVI Reference Guide

ENVI_LAYER_STACKING_DOIT

368

Chapter 2: ENVI Routines


;
envi_file_query, t_fid, $
ns=t_ns, nl=t_nl, nb=t_nb
envi_file_query, d_fid, $
ns=d_ns, nl=d_nl, nb=d_nb
;
nb = t_nb + d_nb
fid = lonarr(nb)
pos = lonarr(nb)
dims = lonarr(5,nb)
;
for i=0L,t_nb-1 do begin
fid[i] = t_fid
pos[i] = i
dims[0,i] = [-1,0,t_ns-1,0,t_nl-1]
endfor
;
for i=t_nb,nb-1 do begin
fid[i] = d_fid
pos[i] = i-t_nb
dims[0,i] = [-1,0,d_ns-1,0,d_nl-1]
endfor
;
; Set the output projection and
; pixel size from the TM file. Save
; the result to disk and use floating
; point output data.
;
out_proj = envi_get_projection(fid=t_fid, $
pixel_size=out_ps)
out_name = testimg
out_dt = 4
;
; Call the layer stacking routine. Do not
; set the exclusive keyword allow for an
; inclusive result. Use cubic convolution
; for the interpolation method.
;
envi_doit, envi_layer_stacking_doit, $
fid=fid, pos=pos, dims=dims, $
out_dt=out_dt, out_name=out_name, $
interp=2, out_ps=out_ps, $
out_proj=out_proj, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI_LAYER_STACKING_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

369

See Also
ENVI_CONVERT_FILE_MAP_PROJECTION
MOSAIC_DOIT

ENVI Reference Guide

ENVI_LAYER_STACKING_DOIT

370

Chapter 2: ENVI Routines

ENVI_MAP_INFO_CREATE
This routine returns an ENVI map information structure for any of the supported map
projections (see Appendix D, ENVI Map Projections in the ENVI Users Guide).
Arbitrary, Geographic, UTM and State Plane map information structures use their
corresponding keyword. All other projections use the PROJ keyword to define the
associated projection. Projections can be defined using ENVI_PROJ_CREATE.
Using the optional keywords you can define the datum, name, units, projection
parameters, pixel size, rotation, and the map coordinate. The result of this routine can
be used for functions that require an input MAP_INFO structure. For example, to
georeference an image, ENVI_SETUP_HEAD requires an input MAP_INFO
structure.
Note
This routine should be used instead of accessing the map information structure
directly.

Syntax
Result = ENVI_MAP_INFO_CREATE()

Keywords
ARBITRARY (optional)
Set this keyword to specify that an Arbitrary projection for the map information is
created. Set the keyword MAP_BASED to create a map based projection. The default
is non map based projection. A map-based projection uses the lower left corner of the
image as the projection origin, while a pixel-based projection (non-map based) uses
the upper left corner as the origin.

DATUM (optional)
Use this keyword to specify the datum for the map information projection. The
default for Geographic is WGS-84 and the default for UTM and State Plane is North
America 1927. All other projections default to no datum. The exact name that ENVI
uses for each datum is listed in the datum.txt file in the map_proj directory of
your ENVI installation.

ENVI_MAP_INFO_CREATE

ENVI Reference Guide

Chapter 2: ENVI Routines

371

GEOGRAPHIC (optional)
Set this keyword to specify that a Geographic projection for the map information is
created.

MAP_BASED (optional)
Set this keyword to specify that the Arbitrary projection should be interpreted as map
based. This keyword does not have any effect for other projections.

MC
Set this keyword to specify the map location tie point. The tie point is the reference
point for a pixel at a known map coordinate. MC is a four elements double precision
array where

mc(0) is the X pixel location corresponding to the X map location, mc(2)

mc(1) is the Y pixel location corresponding to the Y map location, mc(3)

mc(2) is the X map location corresponding to the X pixel location, mc(0)

mc(3) is the Y map location corresponding to the Y pixel location, mc(1)

NAME (optional)
Use this keyword to specify the name of the map information projection. NAME is a
string variable

PARAMS (optional)
Use this keyword to specify the parameters for the map information projection.
PARAMS is a double array with 1 to 15 elements. The number of elements of
PARAMS is determined by the projection type (see the TYPE keyword). PARAMS is
not used with Arbitrary, Geographic, State Plane, or UTM projections. See the ENVI
Map Projections Appendix in the Users Guide for a full list of the projection type and
their corresponding projection parameters. The PARAMS keyword must contain all
projection parameters listed in the ENVI Map Projections Appendix (for the
specified projection) except the datum and name. The datum and name are specified
using the DATUM and NAME keywords, respectively.

PROJ (optional)
Set this optional keyword to specify the projection for the map information. PROJ is
an ENVI projection structure returned from ENVI_PROJ_CREATE or
ENVI_GET_PROJECTION. PROJ is not needed if the keyword ARBITRARY,

ENVI Reference Guide

ENVI_MAP_INFO_CREATE

372

Chapter 2: ENVI Routines

GEOGRAPHIC, STATE_PLANE, or UTM is used. For all other projections, either


set the PROJ keyword or define the projection using the keywords DATUM, NAME,
PARAMS, SOUTH, TYPE, UNITS, and ZONE.

PS
Set this keyword to specify the pixel size of the image. PS is a two element double
precision array where

ps(0) is the X pixel size

ps(1) is the Y pixel size

ROTATION (optional)
Set this keyword to specify the rotation of the image in the defined projection.
Rotation is expressed in degrees clockwise from North.

SOUTH (optional)
Set this keyword to specify that the UTM projection is in the southern hemisphere.

STATE_PLANE (optional)
Set this keyword to specify that a State Plane projection for the map information is
created.

TYPE (optional)
Use this keyword to specify the map information projection type. TYPE is an integer
value corresponding to the projection type. See the ENVI Map Projections Appendix
in the Users Guide for a full list of the projection types and their corresponding
projection value.

UNITS (optional)
Use this keyword to specify the projection units. UNITS is an integer value indicating
the projection units. The function ENVI_TRANSLATE_PROJECTION_UNITS will
convert projection unit strings to integer values. The default UNITS are Degrees for
Geographic, Feet for State Plane and Meters for all other projections.

UTM (optional)
Set this keyword to specify that a UTM projection for the map information is created.

ENVI_MAP_INFO_CREATE

ENVI Reference Guide

Chapter 2: ENVI Routines

373

ZONE (optional)
Use this keyword to specify the UTM or State Plane zone number. ZONE is only
used for UTM and State Plane projections.

Example
This example creates a Geographic map information structure with a Geographic
projection, default datum of WGS-84, default units of Degrees, and a pixel size of
one second (1. / 3600). Set the map tie point for the center of the first pixel (.5,.5) to
34.5 degrees North and 117.4 degrees West. This is one of the simplest uses of
ENVI_MAP_INFO_CREATE.
;
; Set the pixel size and map tie point
;
ps = [1D/3600, 1D/3600]
mc = [0D, 0, -117.4, 34.5]
;
; Create the map information
;
map_info = envi_map_info_create(/geographic, $
mc=mc, ps=ps)

This example creates map information for a UTM projection zone 23 South with
units of kilometers and a North America 1983 datum. Set the map tie point for the
upper left corner of the first pixel to 8339330 North and 177246 East. We use the
keywords to ENVI_MAP_INFO_CREATE instead of first creating a projection
structure and then using the PROJ keyword.
;
; First convert the kilometers to its integer representation
; using ENVI_TRANSLATE_PROJECTION_UNITS
;
units = ENVI_TRANSLATE_PROJECTION_UNITS(km)
; Set the datum and map tie points
;
datum = North America 1983
mc = [0D, 0, 177246, 8339330]
ps=[30, 30]
;
; Now create the UTM map information
;
map_info = ENVI_MAP_INFO_CREATE(/UTM, ZONE=23, /SOUT, $
DATUM = datum, UNITS = units, MC = mc, PS = ps)

ENVI Reference Guide

ENVI_MAP_INFO_CREATE

374

Chapter 2: ENVI Routines

See Also
ENVI_CONVERT_PROJECTION_COORDINATES
ENVI_PROJ_CREATE
ENVI_TRANSLATE_PROJECTION_NAME
ENVI_TRANSLATE_PROJECTION_UNITS

ENVI_MAP_INFO_CREATE

ENVI Reference Guide

Chapter 2: ENVI Routines

375

ENVI_MASK_APPLY_DOIT
Use this program to apply a mask to a file.

Syntax
ENVI_DOIT, ENVI_MASK_APPLY_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

M_FID
Use this keyword to specify the file ID for the mask file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

ENVI Reference Guide

ENVI_MASK_APPLY_DOIT

376

Chapter 2: ENVI Routines

M_POS
Use this keyword to specify the band position of the mask band. M_POS is a single
long value greater than or equal to zero.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify a one-dimension array of band positions indicating the
band numbers to perform the operations on. POS is a long array ranging from 0 to the
number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

VALUE
Use this keyword to specify the mask value. Each masked pixel in the output image
will take the value VALUE.

Example
PRO apply_mask_example
; Initialize ENVI
ENVI, /RESTORE_BASE_SAVE_FILES
ENVI_BATCH_INIT, LOG_FILE = batch_log.txt
; Set the input and output file names
out_name = out_file
ENVI_OPEN_FILE, image_file.bil, R_FID = fid
ENVI_OPEN_FILE, mask_file.dat, R_FID = m_fid
IF (fid EQ -1 OR m_fid EQ -1) THEN BEGIN
ENVI_BATCH_EXIT
RETURN
ENDIF

ENVI_MASK_APPLY_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

377

; Get some useful information about the input data.


ENVI_FILE_QUERY, fid, NS = ns, NL = nl, NB = nb
; Set the keyword parameters
dims = [-1L, 0, ns - 1, 0, nl - 1]
pos = LINDGEN(nb)
m_pos = [0]
; Call the doit
ENVI_MASK_APPLY_DOIT, FID = fid, POS = pos, DIMS = dims, $
M_FID = m_fid, M_POS = m_pos, VALUE = 0, OUT_NAME = out_name, $
IN_MEMORY = 0, R_FID = r_fid
; Exit ENVI
ENVI_BATCH_EXIT
END

ENVI Reference Guide

ENVI_MASK_APPLY_DOIT

378

Chapter 2: ENVI Routines

ENVI_NEURAL_NET_DOIT
Use this program to perform classification using a Neural Net method. Neural Net
classification is a supervised classification where the net is trained on a set of input
regions of interest (ROIs). The keywords ALPHA, ETA, THETA, NUM_SWEEPS,
NUM_LAYERS and RMS_CRIT are associated with training of the net. The optional
keyword THRESH can be used to set the minimum activation threshold a class must
satisfy in order to classified.

Syntax
ENVI_DOIT, ENVI_NEURAL_NET_DOIT

Keywords
ALPHA
Use this keyword to specify the training momentum. ALPHA is a floating point or
double precision number between zero and one.

ACT_TYPE
Use this keyword to specify the type of activation function for training the neural net.
ACT_TYPE is an integer value set to one of the following values:

0 Logistic

1 Hyperbolic

CLASS_NAMES
Use this keyword to specify names for each output class. CLASS_NAMES is an
array of strings with num_classes+1 elements. Remember to set the zero class to
Unclassified.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

ENVI_NEURAL_NET_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

379

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

ETA
Use this keyword to specify the training rate. ETA is a floating point or double
precision number between zero and one.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

LOOKUP
Use this keyword to specify an array specifying the color tables for the classification
image. Each output class can have a unique color triple [r,g,b], LOOKUP is a byte
array of size (3, num_classes+1). Remember that class zero must also have a color
triplet (commonly black [0,0,0]).

NUM_CLASSES
Use this keyword to specify the number of output classes. The number of output
classes is equal to the number of input regions of interest (ROIs) as specified by
ROI_PTR.

NUM_LAYERS
Use this keyword to specify the number of hidden layers in the neural net classifier.
Typically this value is set to zero, one or two.

NUM_SWEEPS
Use this keyword to specify the maximum number of training sweeps to perform
count. The actual number of training sweeps may be less than NUM_SWEEPS if
error criteria has been met, see RMS_CRIT.

ENVI Reference Guide

ENVI_NEURAL_NET_DOIT

380

Chapter 2: ENVI Routines

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

RMS_CRIT
Use this keyword to specify the RMS training error criteria. During training if the
RMS error is less than RMS_CRIT then the training ended and the image is classified
according to the trained neural net.

ROI_ID
Use this keyword to specify an array of ROI IDs returned from a call to
ENVI_GET_ROI_IDS. Each ID in the array will use the corresponding ROI to
calculate both a co-polarization and cross-polarization image.

RULE_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed rule image. This file ID can be used to access the processed data.

RULE_OUT_BNAME (optional)
Use this keyword to specify a string array that contains the output band names for the
rule image.

RULE_OUT_NAME (optional)
Use this keyword to specify an output filename for the rule image. If this item is
present the rule image is automatically saved.
ENVI_NEURAL_NET_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

381

RULE_IN_MEMORY (optional)
Set this keyword to specify that output rule images should be stored in memory.

THETA
Use this keyword to specify the training threshold contribution. THETA is a floating
point or double precision number between zero and one.

THRESH (optional)
Use this keyword to specify an minimum activation threshold a class must have in
order to be classified.

TRAIN
Set this keyword to train the neural net prior to classification. Currently this keyword
must be set.

Example
forward_function envi_get_roi_ids, envi_get_roi_dims_ptr
pro example_envi_neural_net_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtm_mnf.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the dims and pos to classify all
; data (spatially and spectrally) in the file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1L, 0, ns-1, 0, nl-1]

ENVI Reference Guide

ENVI_NEURAL_NET_DOIT

382

Chapter 2: ENVI Routines


pos = lindgen(nb)
out_name = testimg
;
; Restore the ROI file used as the
; trainig pixels. Each ROI in the file
; will be considered on input class
;
envi_restore_rois, bhtm_nd.roi
roi_ids = envi_get_roi_ids(fid=fid, $
roi_colors=lookup, roi_names=class_names)
;
; Specify the neural net training
; criteria.
;
theta = .9
eta = .2
alpha = .9
act_type = 0
rms_crit = .1
num_layers = 3
num_sweeps = 1000
;
; Set the classification variables
;
num_classes = n_elements(roi_ids)
class_names = [Unclassified, class_names]
lookup = reform([0,0,0, $
reform(lookup,3*num_classes)],3,num_classes+1)
;
; Call the doit
;
envi_doit, envi_neural_net_doit, $
fid=fid, pos=pos, dims=dims, $
out_name=out_name, rule_out_name=, $
theta=theta, eta=eta, alpha=alpha, $
num_classes=num_classes, num_sweeps=num_sweeps, $
num_layers=num_layers, act_type=act_type, $
rms_crit=rms_crit, roi_ids=roi_ids, /train, $
class_names=class_names, lookup=lookup
;
; Exit ENVI
;
envi_batch_exit
end

ENVI_NEURAL_NET_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

383

See Also
CLASS_DOIT
CLASS_RULE_DOIT
CLASS_STATS_DOIT

ENVI Reference Guide

ENVI_NEURAL_NET_DOIT

384

Chapter 2: ENVI Routines

ENVI_OPEN_DATA_FILE
Use this routine to open a data file. The types of files that you can open using this
routine include:
ADRG

ERS

NITF

AVHRR

ESA Sharp

NLAPS

BMP

ERA Landsat TM

PCI

DMSP

ESRI GRID

RADARSAT

DOQ

HDF

SeaWiFS

ENVI

IRS Super Structured

SPOT

EOSAT IRS and TM

JERS

Tiff

ERDAS 7.5 and 8.x

MAS50

TopSAR

ER Mapper

MRLC

Syntax
ENVI_OPEN_DATA_FILE, Name

Arguments
NAME
The filename to open. The type of the file is indicated by setting the proper keyword.

Keywords
ACRES (optional)
Set this keyword to specify that the file being opened is a Landsat ACRES file.

ADRG (optional)
Set this keyword to specify that the file being opened is an ADRG file.

ASTER (optional)
Set this keyword to specify that the file being opened is an ASTER file.
ENVI_OPEN_DATA_FILE

ENVI Reference Guide

Chapter 2: ENVI Routines

385

ATSR (optional)
Set this keyword to specify that the file being opened is an ATSR file.

AVHRR (optional)
Set this keyword to specify that the file being opened is an AVHRR file.
Note
To use ENVI_OPEN_DATA_FILE to open an AVHRR file in the ESA_SHARP
format, set the ESA_SHARP keyword (instead of the AVHRR keyword).

BMP (optional)
Set this keyword to specify that the file being opened is a BMP file.

CADRG (optional)
Set this keyword to specify that the file being opened is a CADRG file.

CIB (optional)
Set this keyword to specify that the file being opened is a CIB file.

DIMAP (optional)
Set this keyword to specify that the file being opened is a SPOT 5 DIMAP file.

DMSP (optional)
Set this keyword to specify that the file being opened is a DMSP file.

DOQ (optional)
Set this keyword to specify that the file being opened is a DOQ file.

DRG (optional)
Set this keyword to specify that the file being opened is a DRG file.

ECW (optional)
Set this keyword to specify that the file being opened is a ECW file.

ENVI Reference Guide

ENVI_OPEN_DATA_FILE

386

Chapter 2: ENVI Routines

ENVI (optional)
Set this keyword to specify that the file being opened is an ENVI file.

ENVISAT (optional)
Set this keyword to specify that the file being opened is an ENVISAT file.

EOSAT_IRS (optional)
Set this keyword to specify that the file being opened is an EOSAT IRS file.

EOSAT_TM (optional)
Set this keyword to specify that the file being opened is an EOSAT TM file.

ERMAPPER (optional)
Set this keyword to specify that the file being opened is an ER Mapper file.

EROS_1A (optional)
Set this keyword to specify that the file being opened is an EROS 1A file.

ERS (optional)
Set this keyword to specify that the file being opened is an ERS file.

ESA_SHARP (optional)
Set this keyword to specify that the file being opened is an ESA Sharp file.

ESA_TM (optional)
Set this keyword to specify that the file being opened is an ESA Landsat TM file.

ESRI_GRID (optional)
Set this keyword to specify that the file being opened is an ESRI GRID raster format
file.
Note
The Name argument must use the full path name to the GRID file when this
keyword is used.

ENVI_OPEN_DATA_FILE

ENVI Reference Guide

Chapter 2: ENVI Routines

387

Warning
You must have a licensed version of ESRI ArcGIS 8.x on your system to open an
ESRI GRID raster file.

HDF_SD (optional)
Set this keyword to specify that the file being opened is a HD file containing SD data.

IMAGINE (optional)
Set this keyword to specify that the file being opened is an ERDAS IMAGINE 8.x (or
later) file. This keyword opens both .img and .ige IMAGINE files.

IRS_SUPER (optional)
Set this keyword to specify that the file being opened is an IRS Super Structured file.

JERS (optional)
Set this keyword to specify that the file being opened is a Jers file.

JP2 (optional)
Set this keyword to specify that the file being opened is a JPEG2000 file.

JPEG (optional)
Set this keyword to specify that the file being opened is a JPEG file.

MAS_50 (optional)
Set this keyword to specify that the file being opened is a MAS_50 file.

MRLC (optional)
Set this keyword to specify that the file being opened is a MRLC file.

MODIS (optional)
Set this keyword to specify that the file being opened is a MODIS file.

MRSID (optional)
Set this keyword to specify that the file being opened is a MrSID file.

ENVI Reference Guide

ENVI_OPEN_DATA_FILE

388

Chapter 2: ENVI Routines

NITF (optional)
Set this keyword to specify that the file being opened is a NITF file.

NLAPS (optional)
Set this keyword to specify that the file being opened is a NLAPS file.

PCI (optional)
Set this keyword to specify that the file being opened is a PCI file.

PDS (optional)
Set this keyword to specify that the file being opened is a PDS file.

PICT (optional)
Set this keyword to specify that the file being opened is a PICT file.

PNG (optional)
Set this keyword to specify that the file being opened is a PNG file.

QB_TILE (optional)
Set this optional keyword to specify that the file being opened is a tiled QuickBird
dataset to be opened as a virtual mosaic. A single file ID is returned for the virtual
mosaic.

RADARSAT (optional)
Set this keyword to specify that the file being opened is a RADARSAT file.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
opened data. This file ID can be used to access the processed data.

SEAWIFS (optional)
Set this keyword to specify that the file being opened is a SeaWiFS file.

SPOT (optional)
Set this keyword to specify that the file being opened is a SPOT file.

ENVI_OPEN_DATA_FILE

ENVI Reference Guide

Chapter 2: ENVI Routines

389

SRF (optional)
Set this keyword to specify that the file being opened is a SRF file.

SRTM (optional)
Set this keyword to specify that the file being opened is a SRTM file.

TIFF (optional)
Set this keyword to specify that the file being opened is a TIFF or GEOTIFF file.

TIMS (optional)
Set this keyword to specify that the file being opened is a TIMS file.

TOPSAR (optional)
Set this keyword to specify that the file being opened is a TOPSAR file.

VEGETATION (optional)
Set this keyword to specify that the file being opened is a SPOT Vegetation file.

XWD (optional)
Set this keyword to specify that the file being opened is an XWD file.

Example
pro example_envi_open_data_file
;
; Open a data file
;
fname = lon_spot
envi_open_data_file, fname, /ermapper, r_fid=fid
if (fid eq -1) then return
;
; Query and print the ns, nl, and nb
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
print, ns, nl, nb
end

ENVI Reference Guide

ENVI_OPEN_DATA_FILE

390

Chapter 2: ENVI Routines

ENVI_OPEN_FILE
Use this procedure to open an ENVI file. The value of R_FID will be the reference
for accessing any information about this file.

Syntax
ENVI_OPEN_FILE, Fname

Arguments
Fname
The file name, including the path, of the file to open.

Keywords
NO_INTERACTIVE_QUERY (optional)
Set this optional keyword to suppress bringing up the ENVI Header Information
dialog when a valid header file does not exist for Fname. If this keyword is set and a
valid header file does not exist, the file cannot be opened and an invalid file ID is
returned in the keyword R_FID.

NO_REALIZE (optional)
Set this optional keyword to suppress opening of the Available Bands List. If the
Available Bands List is already open this keyword has no effect.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
opened file. R_FID is a long integer with a value greater than zero. An invalid file ID
is specified as -1.

Example
Use ENVI_OPEN_FILE to open a file. Check and make sure the file was opened
properly before using the returned file ID to perform an ENVI_FILE_QUERY.
; Input file definition
fname = /data/img_001
envi_open_file, fname, r_fid=fid

ENVI_OPEN_FILE

ENVI Reference Guide

Chapter 2: ENVI Routines

391

if (fid eq -1) then return


envi_file_query, fid, ns=ns, nl=nl, nb=nb

See Also
ENVI_FILE_MNG
ENVI_FILE_QUERY
ENVI_PICKFILE

ENVI Reference Guide

ENVI_OPEN_FILE

392

Chapter 2: ENVI Routines

ENVI_OUTPUT_TO_EXTERNAL_FORMAT
Use this program to output image data to external formats. This routines allows
output of ArcView, ASCII, ENVI, ERDAS, ER Mapper, JPEG2000, PCI, and TIFF
formats.

Syntax
ENVI_OUTPUT_TO_EXTERNAL_FORMAT

Keywords
ARCVIEW (optional)
Set this keyword to specify output to a ArcView formatted file.

ASCII (optional)
Set this keyword to specify output to a ASCII formatted file. If the ASCII keyword is
set you must also specify the FIELD keyword.

BLOCK_WIDTH (optional)
Use this keyword to specify a long integer representing horizontal size (in pixels) of
the image block. This keyword is only valid when the IMAGINE keyword is also set.
Valid values are positive integers less than or equal to the image width. The default
value is determined for each image, and is a block size (in pixels) optimized for
writing from ENVI.

BLOCK_HEIGHT (optional)
Use this keyword to specify a long integer representing vertical size (in pixels) of the
image block. This keyword is only valid when the IMAGINE keyword is also set.
Valid values are positive integers less than or equal to the image height. The default
value is determined for each image, and is a block size (in pixels) optimized for
writing from ENVI.

ENVI_OUTPUT_TO_EXTERNAL_FORMAT

ENVI Reference Guide

Chapter 2: ENVI Routines

393

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

ENVI (optional)
Set this keyword to specify output to an ENVI formatted file. If the ENVI keyword is
set you may optionally specify the band names using the OUT_BNAME keyword.

ERDAS (optional)
Set this keyword to specify output to an ERDAS .lan formatted file.

ERMAPPER (optional)
Set this keyword to specify output to a ER Mapper formatted file.

ESRI_GRID (optional)
Set this keyword to specify output to an ESRI GRID raster format file.

IMAGINE (optional)
Set this keyword to specify output to an ERDAS IMAGINE 8.x formatted file.
Any character in the OUT_NAME string that is not valid for the ERDAS filename
convention is changed to an underscore character (_) when using the IMAGINE
keyword.

JP2 (optional)
Set this keyword to specify output to a JPEG2000 formatted file.

ENVI Reference Guide

ENVI_OUTPUT_TO_EXTERNAL_FORMAT

394

Chapter 2: ENVI Routines

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

FIELD (optional)
Use this keyword to specify a two element long array of the ASCII character field
width and precision. The first element of the array specifies the number of characters
in the external field. The second element in the array specifies the number of
positions after the decimal point.

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired. This
keyword is only valid when the ENVI keyword is also set.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. The output file
will be in the format specified by one of the following keywords, ARCVIEW, ASCII,
ENVI, ERMAPPER, ERDAS, PCI or TIFF.

PCI (optional)
Set this keyword to specify output to a PCI formatted file.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands1.

TIFF (optional)
Set this keyword to specify output to a TIFF formatted file.

ENVI_OUTPUT_TO_EXTERNAL_FORMAT

ENVI Reference Guide

Chapter 2: ENVI Routines

395

ENVI_PC_SHARPEN_DOIT
The ENVI_PC_SHARPEN_DOIT procedure computes the Principal Components
spectral sharpening. This routine is used to sharpen a low spatial resolution multiband image using an associated high spatial resolution panchromatic band.

Syntax
ENVI_DOIT, ENVI_PC_SHARPEN_DOIT, DIMS=array, FID=fileID,
HIRES_DIMS=array, HIRES_FID=fileID, HIRES_POS=array
[, /IN_MEMORY] | OUT_NAME=string [, INTERP={0 | 1 | 2}]
[, M_FID=fileID] [, M_POS=array] [, MASK_VALUE=value]
[, OUT_BNAME=string array], POS=array [, R_FID=fileID]

Arguments
None

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]:Unused for this function, set to -1.

DIMS[1]:The starting X pixel. (The first pixel is number zero.)

DIMS[2]:The ending X pixel.

DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

DIMS[4]:The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

ENVI Reference Guide

ENVI_PC_SHARPEN_DOIT

396

Chapter 2: ENVI Routines

HIRES_DIMS
Use this keyword to specify the spatial dimensions of the high spatial resolution
panchromatic band. HIRES_DIMS is a five-element array of long integers with the
following definitions:

HIRES_DIMS[0]:Unused for this function, set to -1.

HIRES_DIMS[1]:The starting X pixel. (The first pixel is number zero.)

HIRES_DIMS[2]:The ending X pixel.

HIRES_DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

HIRES_DIMS[4]:The ending Y pixel.

HIRES_FID
Use this keyword to specify the file ID for the high spatial resolution panchromatic
file. This is the value returned from the keyword R_FID in the ENVI_OPEN_FILE
procedure. HIRES_FID is a long integer with a value greater than zero. An invalid
file ID is specified as -1.

HIRES_POS
Use this keyword to specify the band position of the high spatial resolution
panchromatic band. HIRES_POS is an array of long integers, ranging from zero to
the number of bands-1.

IN_MEMORY (optional)
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

INTERP (optional)
Set this keyword equal to one of the following values to specify the resampling
method:

0 = Nearest Neighbor

1 = Bilinear Interpolation

2 = Cubic Convolution

The low spatial resolution images are resampled to the high resolution space using
the specified resampling method. The default is Nearest Neighbor.

ENVI_PC_SHARPEN_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

397

M_FID (optional)
Use this keyword to specify the file ID for the mask file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

M_POS (optional)
Use this keyword to specify the band position of the mask band. M_POS is a single
long value greater than or equal to zero.

MASK_VALUE (optional)
Use this keyword to specify the output value for the masked pixels. MASK_VALUE
is only used when M_FID and M_POS are specified. The default for MASK_VALUE
is zero.

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

See Also
ENVI_GS_SHARPEN_DOIT
SHARPEN_DOIT

ENVI Reference Guide

ENVI_PC_SHARPEN_DOIT

398

Chapter 2: ENVI Routines

ENVI_PICKFILE
Use this function to pick a filename. This is different than ENVI_SELECT which
selects an open file or band.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = ENVI_PICKFILE()

Keywords
DEFAULT (optional)
Use this optional keyword to specify a default filename and output path.
Note
The OUTPUT keyword must be used for the DEFAULT keyword to take effect.

DIRECTORY (optional)
Set this optional keyword to allow selection of an output directory instead of a file.

FILTER (optional)
Use this optional keyword to specify the filename filter to apply to the file list.

MULTIPLE_FILES (optional)
Set this keyword to allow multiple files to be selected using the Shift-click (to select
multiple contiguous files) or Ctrl-click (to individually select multiple files)
methods.

NO_CHANGE (optional)
Set this optional keyword to inhibit the changing of the current ENVI output or data
directory regardless of what directory the file was selected from. Normally the
directory is updated to the location of the selected file.

ENVI_PICKFILE

ENVI Reference Guide

Chapter 2: ENVI Routines

399

OUTPUT (optional)
Set this optional keyword in order to use the current ENVI output directory instead of
the current ENVI data directory.

TITLE
Use this keyword to specify the title of the file selection widget.

Example
Use ENVI_PICKFILE to select a filename, by default only list the files that have a
.txt extension.
name = envi_pickfile(title=Pick a text file, $
filter=*.txt)
if (name eq ) then return
print, The selected filename is: , name

See Also
ENVI_OPEN_FILE
ENVI_SELECT

ENVI Reference Guide

ENVI_PICKFILE

400

Chapter 2: ENVI Routines

ENVI_PLOT_DATA
Use this procedure to display an XY plot(s) in a new ENVI plot window. Depending
on the dimensions of the Y array one or more plots will be displayed.

Syntax
ENVI_PLOT_DATA, X, Y

Arguments
X
An array of X values to plot. X is an array of N points.

Y
An array of Y values to plot. Y is an array of (N, number of plots).

Keywords
BASE (optional)
Use this optional keyword to specify a named variable that will contain the returned
widget base of the plot window.

GROUP (optional)
Use this optional keyword to specify the group leader for this widget. The default is
the ENVI main base which will remove the plot window when ENVI is exited.

TITLE (optional)
Use this optional keyword to specify the plot window title. The default is ENVI Plot
Window.

PLOT_COLORS (optional)
Use this optional keyword to specify the plot graphic color index. PLOT_COLORS is
a long array of (number of plots), specifying graphic color index.

ENVI_PLOT_DATA

ENVI Reference Guide

Chapter 2: ENVI Routines

401

PLOT_NAMES (optional)
Use this keyword to specify the plot names. PLOT_NAMES is a string array of
(number of plots).

PLOT_STYLES (optional)
Use this optional keyword to specify the plot styles. PLOT_STYLES is long array of
(number of plots), specifying the style index. The available plot style indexes are as
follows:
Value

Description

Solid

Dotted

Dashed

Dash Dot

Dash Dot Dot Dot

Long Dashes

Table 19-4: PLOT_STYLES Keyword Values

PLOT_TITLE (optional)
Use this optional keyword to specify the plot title. PLOT_TITLE is a string.

XOFF (optional)
Use this optional keyword to specify the x offset (in pixels) of the upper-left corner of
the plot window relative to the upper-left corner of the screen. If XOFF is not
specified, the plot window is centered horizontally on the screen.

XTITLE (optional)
Use this optional keyword to specify the X axis title.

YOFF (optional)
Use this optional keyword to specify the y offset (in pixels) of the upper-left corner of
the plot window relative to the upper-left corner of the screen. If YOFF is not
specified, the plot window is centered vertically on the screen.

ENVI Reference Guide

ENVI_PLOT_DATA

402

Chapter 2: ENVI Routines

YTITLE (optional)
Use this optional keyword to specify the Y axis title.

Example
The example plot creates a plot window with two plots.
x = findgen(100)
y = reform([x, sin(x)], 100, 2)
plot_names = [XY Line, SIN(X)]
envi_plot_data, x, y, plot_names=plot_names

See Also
ENVI_READ_COLS

ENVI_PLOT_DATA

ENVI Reference Guide

Chapter 2: ENVI Routines

403

ENVI_PROJ_CREATE
Use this routine to create an ENVI projection structure for any of the supported
projections, see Appendix D, ENVI Map Projections in the ENVI Users Guide.
Using the optional keywords you can define the datum, name, units, and projection
parameters. Additional keywords allow the definition with common defaults for the
Arbitrary, Geographic, State Plane and UTM projections. This routine should be used
instead of accessing the projection structure directly.

Syntax
Result = ENVI_PROJ_CREATE( )

Keywords
ARBITRARY (optional)
Set this keyword to specify that an Arbitrary projection is created. Set the keyword
MAP_BASED to create a map based projection. The default is non map based
projection. A map-based projection uses the lower left corner of the image as the
projection origin, while a pixel-based projection (non-map based) uses the upper left
corner as the origin.

DATUM (optional)
Use this keyword to specify the datum for the projection. The default for Geographic
is WGS-84 and the default for UTM and State Plane is North America 1927. All
other projections default to no datum. The exact name that ENVI uses for each datum
is listed in the datum.txt file in the map_proj directory of the ENVI installation.

GEOGRAPHIC (optional)
Set this keyword to specify that a Geographic projection is created.

MAP_BASED (optional)
Set this keyword to specify that the Arbitrary projection should be interpreted as map
based. This keyword does not have any effect for other projections.

ENVI Reference Guide

ENVI_PROJ_CREATE

404

Chapter 2: ENVI Routines

NAME (optional)
Use this keyword to specify a user defined name for the projection. NAME is a string
variable. The actual projection type is not determined by the value of NAME
instead the projection type is determined by the keyword TYPE, ARBITRARY,
GEOGRAPHIC, STATE_PLANE, or UTM.

PARAMS (optional)
Use this keyword to specify the parameters for the projection. PARAMS is a double
array with 1 to 15 elements. The number of elements of PARAMS is determined by
the projection type (see the TYPE keyword).
PARAMS is not used with Arbitrary, Geographic, State Plane, or UTM projections.
See Appendix D, ENVI Map Projections in the ENVI Users Guide for a full list of
the projection types and their corresponding projection parameters. The PARAMS
keyword must contain all projection parameters listed in the ENVI Map Projections
Appendix (for the specified projection) except the datum and name. See the example
below for an explanation of some common projection parameters. The datum and
name are specified using the DATUM and NAME keywords, respectively.

SOUTH (optional)
Set this keyword to specify that the UTM projection is in the southern hemisphere.

STATE_PLANE (optional)
Set this keyword to specify that a State Plane projection is created.

TYPE (optional)
Use this keyword to specify the projection type. TYPE is an integer value
corresponding to the projection type. See the ENVI Map Projections Appendix in the
Users Guide for a full list of the projection types and their corresponding projection
value.

UNITS (optional)
Use this keyword to specify the projection units. UNITS is an integer value indicating
the projection units. The function ENVI_TRANSLATE_PROJECTION_UNITS will
convert projection unit strings to integer values. The default UNITS are Degrees for
Geographic, Feet for State Plane and Meters for all other projections.

ENVI_PROJ_CREATE

ENVI Reference Guide

Chapter 2: ENVI Routines

405

UTM (optional)
Set this keyword to specify that a UTM projection is created.

ZONE (optional)
Use this keyword to specify the UTM or State Plane zone number. ZONE is only
used for UTM and State Plane projections.

Example
This example creates a geographic projection with default values for the datum
(WGS-84), name (Geographic Lat/Lon), and the units (Degrees). This is one of the
simplest uses of ENVI_PROJ_CREATE.
proj = ENVI_PROJ_CREATE(/geographic)

This example creates a UTM projection for zone 23 South using the North America
1983 datum. The projection will have units of kilometers.
;
; First convert the kilometers to its integer representation
; using ENVI_TRANSLATE_PROJECTION_UNITS and set
; the datum
;
units = ENVI_TRANSLATE_PROJECTION_UNITS(km)
datum = North America 1983
;
; Now create the UTM projection
;
Proj = ENVI_PROJ_CREATE(/utm, zone=23, /south, $
datum=datum, units=units)

This example creates a Transverse Mercator projection. Using the information in


Appendix D, ENVI Map Projections in the ENVI Users Guide, we see that this
projection, ENVI projection type 3, requires the following parameter:
a, b, lat0, lon0, x0, y0, and k0

where
a - the equatorial radius (semi-major axis)
b - the polar radius (semi-minor axis)
lat0 - Latitude of origin of projection
lon0 - Longitude of central meridian
x0 - False easting
y0 - False Northing
k0 - Scale factor at central meridian

ENVI Reference Guide

ENVI_PROJ_CREATE

406

Chapter 2: ENVI Routines

The actual values for the parameters are based on the projection being defined. In this
example, the datum uses the Australian National ellipsoid which provides the values
for a and b. The Latitude of Origin is 0.0 degrees and the Longitude of Central
Meridian is 99 degrees. The false Northing and Easting are 10000000 and 500000,
respectively. The Scale factor is set to .9996. In addition to these parameters, this
projection will use the Australian Geodetic 1966 datum and have the name Australian
Map Grid (AGD 66) Zone 47. We will also use the default of meters for the map
units.
;
; Define the PARAMS values
;
Params = [6378160.0, 6356774.7, $
0.000000, 99.000000, $
500000., 10000000., $
.9996]
;
; Define the Datum and projection name
datum = Australian Geodetic 1966
name = Australian Map Grid (AGD 66) Zone 47
;
; Create the projection
;
proj = ENVI_PROJ_CREATE(type=3, $
name=name, datum=datum, params=params)

See Also
ENVI_CONVERT_PROJECTION_COORDINATES
ENVI_MAP_INFO_CREATE
ENVI_TRANSLATE_PROJECTION_NAME
ENVI_TRANSLATE_PROJECTION_UNITS

ENVI_PROJ_CREATE

ENVI Reference Guide

Chapter 2: ENVI Routines

407

ENVI_QUERY_VERSION
The ENVI_QUERY_VERSION function returns the current version of ENVI.

Syntax
Result = ENVI_QUERY_VERSION()

Return Value
Returns a string containing the current version number of ENVI.

Arguments
None

Keywords
None

Examples
The following lines of code were used in ENVI 4.2:
version = ENVI_QUERY_VERSION()
HELP, version

ENVI printed:
VERSION

ENVI Reference Guide

STRING

4.2

ENVI_QUERY_VERSION

408

Chapter 2: ENVI Routines

ENVI_RADARSAT_GEOREF_DOIT
The ENVI_RADARSAT_GEOREF_DOIT procedure extracts embedded geolocation
points from a processed RADARSAT file. The points are then used to georeference
the RADARSAT data to a specific map projection.
Note
Not all RADARSAT files contain embedded geolocation points. If the RADARSAT
input data does not have geolocation points, ENVI_RADARSAT_GEOREF_DOIT
will be unable to georegister the file.

Syntax
ENVI_DOIT, ENVI_RADARSAT_GEOREF_DOIT [, BACKGROUND=value]
[, DEGREE=value] [, DIMS=array], FID=fileID [, GCP_NAME=string]
[, METHOD={0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}], /IN_MEMORY |
OUT_FNAME=string [, PIXEL_SIZE=array][, PROJ=structure]
[, R_FID=variable] [, SKIP_LINES=value]

Arguments
None.

Keywords
BACKGROUND (optional)
Use this keyword to specify the pixel value for the background area. All background
pixels are set to this value. The default value is zero.

DEGREE (optional)
Use this optional keyword to specify the degree of the polynomial warp when the
METHOD keyword is set to either 3 (Polynomial with Nearest Neighbor), 4
(Polynomial with Bilinear), or 5 (Polynomial with Cubic Convolution). The default
setting of this keyword is 1 (DEGREE = 1).

DIMS (optional)
Use this optional keyword to specify the spatial dimensions on which to perform the
operation (the full file is specified by default).

ENVI_RADARSAT_GEOREF_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

409

The DIMS keyword is set to a five-element array of long integers with the following
definitions:
Array Element

Description

DIMS[0]

Unused for this function, set to 1

DIMS[1]

The starting X pixel.


Note - The first pixel is number zero.

DIMS[2]

The ending X pixel.

DIMS[3]

The starting Y pixel.


Note - The first pixel is number zero.

DIMS[4]

The ending Y pixel.

FID
Use this keyword to specify the file ID for the RADARSAT input file. This ID is the
value returned from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is
a long integer with a value greater than zero. An invalid file ID is specified as 1.

GCP_NAME (optional)
Use this keyword to specify the name of the output file to contain the extracted
geolocation points. If this keyword is not set, the points are not saved to disk.

IN_MEMORY (optional)
Set this keyword to store the output in memory. If IN_MEMORY is not set, output is
stored on disk by default.

ENVI Reference Guide

ENVI_RADARSAT_GEOREF_DOIT

410

Chapter 2: ENVI Routines

METHOD (optional)
Use this optional keyword to specify an integer value that indicates the methods used
to warp and resample the image. The following table shows the values that represent
each possible combination of warping and resampling methods.
Value

Warping and Resampling Methods

RST (Rotation, Scaling, and Translation) with Nearest


Neighbor, which is the default setting

RST with Bilinear

RST with Cubic Convolution

Polynomial with Nearest Neighbor Default method

Polynomial with Bilinear

Polynomial with Cubic Convolution

Triangulation with Nearest Neighbor

Triangulation with Bilinear

Triangulation with Cubic Convolution

The default is METHOD = 3, Polynomial with Nearest Neighbor.

OUT_FNAME (optional)
Use this keyword to specify an output filename for the resulting data. If
OUT_FNAME is not set, the output default is MEMORY. If the keyword
IN_MEMORY is set, this keyword is not needed.

PIXEL_SIZE (optional)
A two-element array for the output pixel size [x, y]. If PIXEL_SIZE is not specified,
the default is [12.5, 12.5] in meters.

ENVI_RADARSAT_GEOREF_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

411

PROJ (optional)
Use this optional keyword to specify the projection of the resulting data. PROJ
cannot be set to the Arbitrary projection. PROJ is a projection structure returned from
ENVI_PROJ_CREATE or ENVI_GET_PROJECTION. The default projection is
UTM.

R_FID (optional)
Use this optional keyword to specify a named variable to contain the file ID for the
resulting processed data. This file ID can be used to subsequently access the resulting
processed data.

SKIP_LINES (optional)
The number of lines to skip when extracting the GCPs. Default is 100.

Example
Some example code for using the programmatic interface is shown below.
fname = C:\my_radarsat_data
ENVI_OPEN_DATA_FILE, fname, R_FID = fileID, /RADARSAT
projection = ENVI_PROJ_CREATE(/UTM, ZONE = 13)
pixelSize = [10, 10]
gcpFile = C:\temp\DAT_01.pts
outputFilename = C:\temp\radarsat
background = 100
ENVI_DOIT, ENVI_RADARSAT_GEOREF_DOIT, FID = fileID,$
PROJ = projection, PIXEL_SIZE = pixelSize, METHOD = 3, $
DEGREE = 1, SKIP_LINES = 100, GCP_NAME = gcpFile, $
OUT_FNAME = outputFilename

ENVI Reference Guide

ENVI_RADARSAT_GEOREF_DOIT

412

Chapter 2: ENVI Routines

ENVI_READ_COLS
Use this procedure to read ASCII column data.

Syntax
ENVI_READ_COLS, Name, Values

Arguments
Name
The name of the file to read from.

Values
A named variable containing the values read from file.

Keywords
ERROR
Use this keyword to specify a named variable that will hold the value of the error
flag. If this variable is set equal to one, there was a read error. A value of zero
indicates no error.

HEAD
Use this keyword to specify a string array that will contain the column headers of the
file being read.

READ_HEAD
Set this keyword to read the column header and store the result in the string array
specified by the keyword HEAD.

READ_SKIP (optional)
Set this optional keyword to saves all skipped lines in the array specified by the SKIP
keyword. Lines are only skipped when they cannot be decoded into the proper values.

ENVI_READ_COLS

ENVI Reference Guide

Chapter 2: ENVI Routines

413

SKIP
Use this keyword to specify a string array that will contain any skipped lines. The
keyword must be specified if READ_SKIP is set.

ENVI Reference Guide

ENVI_READ_COLS

414

Chapter 2: ENVI Routines

ENVI_REGISTER_DOIT
Use this program to warp image data. This routine can be used to perform image-toimage or image-to-map registration. The keyword PTS is used to specify the base
points and the corresponding input image warp points. The goal is to warp the image
so that the warp points align with the base points. If the base and warp points are in
pixel coordinates, image-to-image registration is performed and both a base and warp
file ID must be specified. If the base points are in map coordinates and the warp
points are in pixel coordinates, then image-to-map registration is performed and only
the warp file ID is specified.

Syntax
ENVI_DOIT, ENVI_REGISTER_DOIT

Keywords
B_FID (optional)
Use this optional keyword to specify the file ID for the base file. B_FID is only
specified when performing image-to-image warping. The goal is to warp the warp
image (W_FID) so it aligns with the base image (B_FID). This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

BACKGROUND (optional)
Use this optional keyword to specify the output image background value. All pixels
outside the warped image boundary will be set to the value specified by
BACKGROUND. The default for BACKGROUND is zero.

DEGREE (optional)
Use this optional keyword to specify the degree of the warping polynomial for the
polynomial method. The degree of the polynomial is limited by the number of GCPs
and you must make sure that #GCPs > (degree + 1)2. DEGREE has no effect for RST
and triangulation methods. The default for DEGREE is one.

ENVI_REGISTER_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

415

IN_MEMORY (optional)
Use this optional keyword to specify that output should be stored in memory. If
IN_MEMORY is not set, output will be stored on disk and OUT_NAME must be
specified.

METHOD (optional)
Use this optional keyword to specify the warping method to use. Set METHOD to
one of the following;

0 RST with nearest neighbor

1 RST with bilinear

2 RST with cubic convolution

3 Polynomial with nearest neighbor

4 Polynomial with bilinear

5 Polynomial with cubic convolution

6 Triangulation with nearest neighbor

7 Triangulation with bilinear

8 Triangulation with cubic convolution

The default is METHOD = 3, Polynomial with nearest neighbor.

OUT_BNAME (optional)
Use this optional keyword to specify a string array of output band names, if desired.

OUT_NAME (optional)
Use this optional keyword to specify an output file name for the resulting data. If the
keyword IN_MEMORY is set, this keyword is not needed.

PIXEL_SIZE (optional)
Use this optional keyword to specify a double precision array containing the pixel
size of the output image in X and Y. The pixel size should be specified in the units
contained in the projection structure passed to the PROJ keyword. The default is
PIXEL_SIZE = [1.0d, 1.0d].

ENVI Reference Guide

ENVI_REGISTER_DOIT

416

Chapter 2: ENVI Routines

PROJ (optional)
Use this optional keyword to specify the projection of the X and Y map coordinates
specified in the PTS array when performing image-to-map registration. PROJ must
be set when performing image-to-map registration. PROJ is a projection structure
returned from ENVI_GET_PROJECTION or ENVI_PROJ_CREATE.

PTS
Use this keyword to specify an array of the X and Y positions of the base and warp tie
points. PTS should be specified in double precision. The dimensions of the array are
(4, #points) where the base and warp points for image-to-image are defined as:

pts(0, #points) X base points

pts(1, #points) Y base points

pts(2, #points) X warp points

pts(3, #points) Y warp points

and for image-to-map to map and warp points are defined as:

pts(0, #points) X map points

pts(1, #points) Y map points

pts(2, #points) X image points

pts(3, #points) Y image points

Note
This routine converts any variable used for PTS to double precision. It additionally
converts X and Y base points to X and Y map points.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

W_DIMS
Use this keyword to specify the spatial dimensions of the warp image (W_FID) on
which to perform the operation. DIMS is a five-element array of long integers with
the following definitions:

DIMS[0]: Unused for this function, set to -1.

ENVI_REGISTER_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

417

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

W_FID
Use this keyword to specify the file ID for the warp file. This is the file ID of the
image that is warped to the base points. This is the value returned from the keyword
R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer with a value
greater than zero. An invalid file ID is specified as -1.

W_POS
Use this keyword to specify an array of band positions for the warp image indicating
the band numbers on which to perform the operation. POS is an array of long
integers, ranging from zero to the number of bands-1.

X0 (optional)
Use this optional keyword to specify the x location (in pixel coordinates for image-toimage or map coordinates for image-to-map) of the upper-left pixel of the output
image.

XSIZE (optional)
Use this keyword to specify the output image x size. This value is in pixels for imageto-image or output map units for image-to-map.

Y0 (optional)
Use this optional keyword to specify the y location (in pixel coordinates for image-toimage or map coordinates for image-to-map) of the upper-left pixel of the output
image.

YSIZE (optional)
Use this keyword to specify the output image y size. This value is in pixels for imageto-image or output map units for image-to-map.

ENVI Reference Guide

ENVI_REGISTER_DOIT

418

Chapter 2: ENVI Routines

ZERO_EDGE (optional)
Set this keyword to specify that the edges outside of any triangles be set to the value
specified by BACKGROUND. The keyword is only used for Triangulation when the
METHOD keyword is set to 6, 7, or 8.

Example
forward_function envi_translate_projection_units, $
envi_proj_create
pro example_envi_register_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS and POS to keywords
; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Setup the points file with the map
; coordinates for know pixel locations and
; create projection for the map coordinates.
; Set the output pixel size to 30 meters.
;
pts = [[474367.50, 4264987.50, 0.0, 0.0], $
[491895.00, 4261155.00, ns-1, 0.0], $
[489720.00, 4250587.50, ns-1, nl-1], $

ENVI_REGISTER_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

419

[471847.50, 4254292.50, 0.0, nl-1]]


;
; Create the projection of the map coordinates
;
units = envi_translate_projection_units(Meters)
proj = envi_proj_create(/utm, zone=13, $
datum=North America 1927, units=units)
pixel_size = [30., 30.]
;
; Perform the image-to-map registration.
envi_doit, envi_register_doit, $
w_fid=fid, w_pos=pos, w_dims=dims, $
method=2, out_name=out_name, $
pts=pts, pixel_size=pixel_size, $
proj=proj, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

See Also
ENVI_CONVERT_FILE_COORDINATES
ENVI_CONVERT_FILE_MAP_PROJECTION
ENVI_CONVERT_PROJECTION_COORDINATES

ENVI Reference Guide

ENVI_REGISTER_DOIT

420

Chapter 2: ENVI Routines

ENVI_REPORT_ERROR
The ENVI_REPORT_ERROR procedure reports error message strings through the
standard ENVI error reporting mechanism. The default title of the displayed dialog
provided by this routine is ENVI Error. The default button provided by the
displayed dialog is Ok.

Syntax
ENVI_REPORT_ERROR, Err_string [, /CANCEL] [, /MESSAGE] [, /QUESTION]
[, VALUE=variable] [, /WARNING]

Arguments
Err_string
A string containing the text that follows the title and precedes any buttons within the
dialog provided by this routine.

Keywords
CANCEL
Use this keyword to display a Cancel button after the Ok or Yes button within the
dialog. If the Cancel button is pressed, a value of -1 is returned for the VALUE
keyword.

MESSAGE
Use this keyword to change the title of the dialog to ENVI Message.

QUESTION
Use this keyword to change the title of the dialog to ENVI Question and the Ok
button to Yes and No buttons. If Yes is pressed, a value of 1 is returned for the
VALUE keyword. If No is pressed, a value of 0 is returned for the VALUE keyword.

VALUE
Use this keyword to specify a named variable that will contain the value of any
button pressed within the dialog.

ENVI_REPORT_ERROR

ENVI Reference Guide

Chapter 2: ENVI Routines

421

WARNING
Use this keyword to change the title of the dialog to ENVI Warning.

ENVI Reference Guide

ENVI_REPORT_ERROR

422

Chapter 2: ENVI Routines

ENVI_REPORT_INC
Use this procedure to set the increment used for tiled processing. This value is shown
in ENVI status windows as a value in the text box labeled Inc:

Syntax
ENVI_REPORT_INC, Base, Num_tiles

Arguments
Base
The base ID of the status window widget.

Num_tiles
The total number of processing cycles. Typically this is equal to the number of tiles.

Example
ENVI_REPORT_INC should be called before the actual processing loop begins:
envi_report_inc, base, num_tiles
for i=0,num_tiles-1 do begin
envi_report_stat,base, i, num_tiles
.
.
algorithm here
.
.
endfor

See Also
ENVI_REPORT_STAT
ENVI_REPORT_INIT

ENVI_REPORT_INC

ENVI Reference Guide

Chapter 2: ENVI Routines

423

ENVI_REPORT_INIT
This procedure displays an ENVI status reporting box showing the percentage of the
function completed and the increment in use. It also provides a Cancel button for the
function. This function is called to initialized the status window and again after the
processing is finished.

Figure 21-3: Processing Status Dialog

Syntax
ENVI_REPORT_INIT, Rstr

Arguments
Rstr
An array of strings to display in the status window. Each element in the array is
displayed on a new line.

Keywords
BASE
Use this keyword to specify a named variable that will contain the widget base used
to display the status window. The base value returned from initialization must be
supplied to ENVI_REPORT_INIT when removing the status window.

ENVI Reference Guide

ENVI_REPORT_INIT

424

Chapter 2: ENVI Routines

FINISH
Set this keyword to remove the status window after processing has finished. Note that
the BASE keyword must be set equal to the same base value as was specified when
the window was created.

INTERRUPT
Set this keyword to allow processing interrupts using the Cancel button.

TITLE
Set this keyword equal to the string to be displayed in the status windows title bar.

Example
The following commands would create a window like the one shown above.
if(in_memory) then ostr = Output to Memory $
else ostr = Output File: + out_fname
rstr = ["Input File :" + fname, ostr]
envi_report_init, rstr, title="USGS Munsell", base=base

This function also must be called at the end of processing to remove the report
widget:
envi_report_init, base=base, /finish

See Also
ENVI_REPORT_STAT
ENVI_REPORT_INC

ENVI_REPORT_INIT

ENVI Reference Guide

Chapter 2: ENVI Routines

425

ENVI_REPORT_STAT
This procedure updates the processing status percent completed as tile processing
occurs. Each time this procedure is called the widget is updated based on the values
of the arguments Num and Den.

Syntax
ENVI_REPORT_STAT, Base, Num, Den

Arguments
Base
The base ID of the status window widget to be updated. This is the value returned
from the ENVI_REPORT_INIT at initialization

Num
A variable which serves as a counter for the number of tiles processed. The percent
completed is determined by the ratio of Num over Den.

Den
The total number of tiles to be processed. The percent completed is determined by the
ratio of Num over Den.

Keywords
CANCEL
Use this keyword to specify a named variable that returns the status of the cancel
button. A returned value of 1 indicates the cancel button was pressed, 0 is
returned otherwise. This keyword only has meaning if INTERUPT was specified in
ENVI_REPORT_INIT.

ENVI Reference Guide

ENVI_REPORT_STAT

426

Chapter 2: ENVI Routines

Example
This example shows how to update the percentage completed for an ENVI status
report window created with ENVI_REPORT_INIT.
for i=0, num_tiles-1 do begin
envi_report_stat, base, i, num_tiles
.
the user function and tiling is done here
.
endfor

Notes
The parameters Num and Den are used to form the ratio (Num/Den)*100 for
calculation of the percent complete. In the example above, the percent complete
would be calculated as (i/num_tiles)*100.

See Also
ENVI_REPORT_INIT
ENVI_REPORT_INC

ENVI_REPORT_STAT

ENVI Reference Guide

Chapter 2: ENVI Routines

427

ENVI_RESAMPLE_SPECTRA
The ENVI_RESAMPLE_SPECTRA procedure spectrally resamples individual
spectra.

Syntax
ENVI_RESAMPLE_SPECTRA, I_WL, I_Spec, O_WL, O_Spec
[, BAD_VALUE=value] [, INTERLEAVE={0 | 1 | 2}] , OUT_DT=integer
[, OUT_FWHM=array]

Arguments
I_WL
A one-dimensional array of input wavelengths corresponding to the input spectra
(I_Spec).

I_Spec
A one-dimensional array of input spectra to be resampled.

O_WL
A one-dimensional array containing the output wavelengths to resample to. This
argument must have the same units as I_WL.

O_Spec
A one-dimensional array containing the resampled output spectra.

Keywords
BAD_VALUE (optional)
Use this optional keyword to specify a value to use for spectra that fall outside the
input wavelength range. In this case, no extrapolation will be performed. All spectra
values equal to BAD_VALUE are considered bad values. BAD_VALUE is a single
number.

ENVI Reference Guide

ENVI_RESAMPLE_SPECTRA

428

Chapter 2: ENVI Routines

INTERLEAVE (optional)
Use this optional keyword to specify the following interleave type:

0 = BSQ format

1 = BIL format

2 = BIP format.

OUT_DT
Set this keyword to indicate the IDL data type of the output data using the following
IDL convention:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

OUT_FWHM (optional)
Use this optional keyword to specify a floating point array of full-width-halfmaximum responses for each output band. The number of elements in this array is
equal to the number of output bands.

ENVI_RESAMPLE_SPECTRA

ENVI Reference Guide

Chapter 2: ENVI Routines

429

ENVI_RESTORE_ROIS
This procedure is used to restore a previously saved Region of Interest (ROI) file.

Syntax
ENVI_RESTORE_ROIS, Fname

Arguments
Fname
The filename of the saved ROI file.

Example
Restore the ROI file wetlands.roi. saved in the directory d:\data\tm.
envi_restore_rois, d:\data\tm\wetlands.roi

See Also
ENVI_GET_ROI
ENVI_GET_ROI_DIMS_PTR
ENVI_GET_ROI_IDS
ENVI_SAVE_ROIS

ENVI Reference Guide

ENVI_RESTORE_ROIS

430

Chapter 2: ENVI Routines

ENVI_ROI_TO_IMAGE_DOIT
Use this program to create a classification image from ROIs. Each input ROI
represents a class in the output image.

Syntax
ENVI_DOIT, ENVI_ROI_TO_IMAGE_DOIT

Keywords
CLASS_VALUES
Set this keyword to specify the values for the output classes. CLASS_VALUES is a
long array specifying the class value for the corresponding ROI_IDS. The class value
of zero is reserved for the Unclassified class.

FID
Use this keyword to specify the file ID associated with the ROIs. FID is used to get
the number of samples and number of lines for the output file. This is the value
returned from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a
long integer with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY (optional)
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

ENVI_ROI_TO_IMAGE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

431

ROI_IDS
Use this keyword to specify the ROI Ids to turn into classes. Each ROI takes on the
class values specified by CLASS_VALUES, the value of zero is reserved for the
unclassified class. ROI_ID is an array of ROI Ids returned from the function
ENVI_GET_ROI_IDS.

Example
forward_function envi_get_roi_ids
pro example_envi_roi_to_image_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file associated with
; the ROIs
;
envi_open_file, bhtm_mnf.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Restore the ROI file and get all
; the available ROI ids.
;
envi_restore_rois, bhtm_nd.roi
roi_ids = envi_get_roi_ids()
if (roi_ids[0] eq -1) then return
;
; Set the necessary variables
;
out_name = testimg
class_values = lindgen(n_elements(roi_ids))+1
;
; Call the doit
;
envi_doit, envi_roi_to_image_doit, $
fid=fid, roi_ids=roi_ids, out_name=out_name, $

ENVI Reference Guide

ENVI_ROI_TO_IMAGE_DOIT

432

Chapter 2: ENVI Routines


class_values=class_values
;
; Exit ENVI
;
envi_batch_exit
end

ENVI_ROI_TO_IMAGE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

433

ENVI_SAVE_ROIS
Use this program to save ROIs from within ENVI. The program accepts the output
ROI filename and a list of ROIs to save.

Syntax
ENVI_SAVE_ROIS, Filename, Roi_ids

Arguments
Filename
The output filename for the saved ROIs.

ROI_ids
The ROI IDs to save to the output Filename. This is the value returned from
ENVI_GET_ROI_IDS or ENVI_CREATE_ROI.

Example
roi_ids = envi_get_roi_ids()
envi_save_rois, test.roi, roi_ids

See Also
ENVI_CREATE_ROI
ENVI_DEFINE_ROI
ENVI_GET_ROI
ENVI_GET_ROI_DATA
ENVI_GET_ROI_DIMS_PTR
ENVI_GET_ROI_IDS
ENVI_GET_ROI_INFORMATION
ENVI_RESTORE_ROIS

ENVI Reference Guide

ENVI_SAVE_ROIS

434

Chapter 2: ENVI Routines

ENVI_SEAWIFS_GEOMETRY_DOIT
The ENVI_SEAWIFS_GEOMETRY_DOIT procedure calculates the geometry for
HDF and CEOS format SeaWiFS data. This procedure extracts header information
and calculates geometry values for each pixel. The following values can be calculated
with this routine:

Latitude and Longitude

Sensor and Sun Positions:

Azimuth Angle The direction from each pixel to the sensor or sun.
North equals 0 degrees, and the angles increase in clockwise direction (for
example, East equals 90).

Zenith Angle The direction measured vertically from each pixel to the
sensor or sun. Straight above the pixel equals 0 degrees.

UTC Time.

Syntax
ENVI_DOIT, 'ENVI_SEAWIFS_GEOMETRY_DOIT' [, CEOS=string]
[, COMP_FLAG=bitmask], DIMS=array, FID=fileID, /IN_MEMORY |
OUT_NAME=string [, OUT_BNAME=string array] [OUT_DT={4 | 5}]
[, R_FID=variable]

Arguments
None

Keywords
CEOS (optional)
Use this optional keyword to specify the name of the CEOS Annotation file
containing the geospatial parameters.
Note
If this keyword is not set, the file is assumed to be in HDF format.

ENVI_SEAWIFS_GEOMETRY_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

435

COMP_FLAG (optional)
Use this optional keyword to indicate which geometry values are calculated. The
following table shows the values that represent each resulting geometry.
Value

Calculated Geometry

Latitude

Longitude

Sensor Azimuth

Sensor Zenith

16

Solar Azimuth

32

Solar Zenith

64

UTC Time

This keyword is set bitwise to allow multiple results by adding integer values
together. For example, to calculate just longitude (value = 2) and UTC time (value =
64), set the COMP_FLAG keyword to 66 (COMP_FLAG = 66), which is 2 + 64.
If this keyword is not set, all the geometry values are calculated by default.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. The DIMS keyword is set to a five-element array of long integers with the
following definitions:
Array Element
DIMS[0]

ENVI Reference Guide

Description
Unused for this function, set to 1

ENVI_SEAWIFS_GEOMETRY_DOIT

436

Chapter 2: ENVI Routines

Array Element
DIMS[1]

Description
The starting X pixel.
Note - The first pixel is number zero.

DIMS[2]

The ending X pixel.

DIMS[3]

The starting Y pixel.


Note - The first pixel is number zero.

DIMS[4]

The ending Y pixel.

FID
Use this keyword to specify the file ID for the input file. This ID is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as 1.

IN_MEMORY
Set this keyword to store the output in memory. If IN_MEMORY is not set, output is
stored on disk by default.

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired.

OUT_DT (optional)
Set this optional keyword to an integer value that indicates the IDL data type of the
output data. The following table shows the IDL convention used for this keyword.
Value

Data Type

Byte (8-bits)

Integer (16-bits)

Long Integer (32-bits)

ENVI_SEAWIFS_GEOMETRY_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

437

Value

Data Type

Floating-point (32-bits)

Double-precision Floating-point (64-bits)

Complex (2x32-bits)

Double-precision Complex (2x64-bits)

12

Unsigned Integer (16-bits)

13

Unsigned Long Integer (32-bits)

14

Long 64-bit Integer

15

Unsigned Long 64-bit Integer

Note
You may lose precision if you specify any data type other than floating-point
(OUT_DT = 4) or double-precision floating-point (OUT_DT = 5).
The default setting is OUT_DT = 4 (floating-point).

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

R_FID (optional)
Use this keyword to specify a named variable to contain the file ID for the processed
data. This file ID can be used to subsequently access the processed data.

Examples
See the example code provided for ENVI_SEAWIFS_GEOREF_DOIT.

ENVI Reference Guide

ENVI_SEAWIFS_GEOMETRY_DOIT

438

Chapter 2: ENVI Routines

See Also
ENVI_SEAWIFS_GEOREF_DOIT

ENVI_SEAWIFS_GEOMETRY_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

439

ENVI_SEAWIFS_GEOREF_DOIT
The ENVI_SEAWIFS_GEOREF_DOIT procedure georeferences HDF and CEOS
format SeaWiFS data. This procedure extracts header information to perform a
precision geocoding of the SeaWiFS data based on a complete geometry model of the
earth and satellite orbit.

Syntax
ENVI_DOIT, ENVI_SEAWIFS_GEOREF_DOIT [, BACKGROUND=value]
[, CEOS=string] [, DEGREE=value], DIMS=array, FID=fileID
[, GCP_NAME=string] [, GCP_PTS=variable], /IN_MEMORY |
OUT_NAME=string [, OUT_BNAME=string array],
OUT_PROJ=structure, POS=array [, /PTS_ONLY] [, R_FID=variable]
[, WARP_X=integer] [, WARP_Y=integer],
WARP_METHOD={0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8} [, /ZERO_EDGE]

Arguments
None

Keywords
BACKGROUND (optional)
Use this keyword to specify the pixel value for the background area. All background
pixels are set to this value. The default value is zero.

CEOS (optional)
Use this optional keyword to specify the name of the CEOS Annotation file
containing the geospatial parameters.
Note
If this keyword is not set, the file is assumed to be in HDF format.

DEGREE (optional)
Use this optional keyword to specify the degree of the polynomial warp when the
WARP_METHOD keyword is set to either 3 (Polynomial with Nearest Neighbor), 4

ENVI Reference Guide

ENVI_SEAWIFS_GEOREF_DOIT

440

Chapter 2: ENVI Routines

(Polynomial with Bilinear), or 5 (Polynomial with Cubic Convolution). The default


setting of this keyword is 1 (DEGREE = 1).

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. The DIMS keyword is set to a five-element array of long integers with the
following definitions:
Array Element

Description

DIMS[0]

Unused for this function, set to 1

DIMS[1]

The starting X pixel.


Note - The first pixel is number zero.

DIMS[2]

The ending X pixel.

DIMS[3]

The starting Y pixel.


Note - The first pixel is number zero.

DIMS[4]

The ending Y pixel.

FID
Use this keyword to specify the file ID for the input file. This ID is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as 1.

GCP_NAME (optional)
Use this keyword to specify the name of the output file to contain the GCPs (Ground
Control Points). If this keyword is not set, the points are not saved to disk.

GCP_PTS (optional)
Use this keyword to specify a named variable to contain the GCPs (Ground Control
Points).

ENVI_SEAWIFS_GEOREF_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

441

IN_MEMORY
Set this keyword to store the output in memory. If IN_MEMORY is not set, output is
stored on disk by default.

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output filename for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OUT_PROJ
Use this keyword to specify the projection of the resulting data. OUT_PROJ cannot
be set to the Arbitrary projection. OUT_PROJ is a projection structure returned from
ENVI_PROJ_CREATE or ENVI_GET_PROJECTION.

POS
Use this keyword to specify an array of band positions indicating the band numbers
on which to perform the operation. POS is an array of long integers that range from
zero to Nb 1, where Nb is the number of bands available.

PTS_ONLY (optional)
Set this keyword to compute only the GCPs (Ground Control Points). If this keyword
is set, the input image is not warped.

R_FID (optional)
Use this keyword to specify a named variable to contain the file ID for the processed
data. This file ID can be used to subsequently access the processed data.

WARP_X (optional)
Use this keyword to specify the number of x warp points to be used for the
georeferencing process. The default number of points is 50.

WARP_Y (optional)
Use this keyword to specify the number of y warp points to be used for the
georeferencing process. The default number of points is 50.

ENVI Reference Guide

ENVI_SEAWIFS_GEOREF_DOIT

442

Chapter 2: ENVI Routines

WARP_METHOD
Use this keyword to specify an integer value that indicates the methods used to warp
and resample the image.
The following table shows the values that represent each possible combination of
warping and resampling methods.
Value

Warping and Resampling Methods

RST (Rotation, Scaling, and Translation) with


Nearest Neighbor

RST with Bilinear

RST with Cubic Convolution

Polynomial with Nearest Neighbor

Polynomial with Bilinear

Polynomial with Cubic Convolution

Triangulation with Nearest Neighbor

Triangulation with Bilinear

Triangulation with Cubic Convolution

ZERO_EDGE (optional)
Set this keyword to specify that the edges outside of any triangles for the
triangulation method are set to the value specified by the BACKGROUND keyword.
The ZERO_EDGE keyword is only used when the WARP_METHOD keyword is set
to either 6 (Triangulation with Nearest Neighbor), 7 (Triangulation with Bilinear), or
8 (Triangulation with Cubic Convolution).

ENVI_SEAWIFS_GEOREF_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

443

Note
The ZERO_EDGE keyword is set (/ZERO_EDGE or ZERO_EDGE = 1) by
default. To disable this default behavior, explicitly set the ZERO_EDGE keyword
to zero (ZERO_EDGE = 0).

Examples
The following sample lines of code show how to call this routine to georeference an
an HDF format SeaWiFS file named S1998036093739.L1A_HORB:
name = "S1998036093739.L1A_HORB"
ENVI_OPEN_FILE, name, R_FID = fid, /NO_REALIZE
out_name = seawifs_warp.img
out_proj = ENVI_PROJ_CREATE(/GEOGRAPHIC)
warp_method = 6
dims = [-1, 0, 500, 0, 500]
pos = [0, 1, 2, 3]
warp_x = 50
warp_y = 50
ENVI_SEAWIFS_GEOREF_DOIT, FID = fid, OUT_NAME = out_name, $
OUT_PROJ = out_proj, DIMS = dims, POS = pos, WARP_X = warp_x, $
WARP_Y = warp_y, WARP_METHOD = warp_method, BACKGROUND = 0, $
/ZERO_EDGE, R_FID = r_fid
out_name = c:\temp\test_geom.img
comp_flag = 42
ENVI_SEAWIFS_GEOMETRY_DOIT, FID = fid, DIMS = dims, $
OUT_DT = out_dt, OUT_NAME = out_name, OUT_BNAME = out_bname, $
COMP_FLAG = comp_flag

See Also
ENVI_SEAWIFS_GEOMETRY_DOIT

ENVI Reference Guide

ENVI_SEAWIFS_GEOREF_DOIT

444

Chapter 2: ENVI Routines

ENVI_SEGMENT_DOIT
Use this program to segment a classification image into unique spatially contiguous
blobs. Blobs can be created with a minimum population and either four or eight
neighbors.

Syntax
ENVI_DOIT, ENVI_SEGMENT_DOIT

Keywords
ALL_NEIGHBORS
Use this keyword to specify the connectivity for segmentation blobs. If set to one all
eight surrounding neighbors are used to connect elements of a blob otherwise set this
keyword to zero to specify that only four (up, down, left, right) pixels form
connections.

CLASS_PTR
Use this keyword to specify the classes to segment. CLASS_PTR is a long array of
class numbers ranging from zero (Unclassified) to the number of classes.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]:Unused for this function, set to -1.

DIMS[1]:The starting X pixel. (The first pixel is number zero.)

DIMS[2]:The ending X pixel.

DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

DIMS[4]:The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.
ENVI_SEGMENT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

445

IN_MEMORY (optional)
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

MIN_POPULATION (optional)
Use this keyword to specify the minimum number of pixels that form a segmentation
blob. The default value for MIN_POPULATION is zero.

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_envi_segment_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtm_sam.img, r_fid=fid

ENVI Reference Guide

ENVI_SEGMENT_DOIT

446

Chapter 2: ENVI Routines


if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform
; the segmentation on all the entire
; spatial image but segment only
; the first class (the Unclassified
; class is the zero class). There must
; at least 50 pixels in a segment
; are connected with any of the
; eight neighbors.
;
envi_file_query, fid, ns=ns, nl=nl
dims = [-1, 0, ns-1, 0, nl-1]
pos = [0]
out_name = testimg
min_population = 50
class_ptr = [1]
;
; Perform the segmentation.
;
envi_doit, envi_segment_doit, $
fid=fid, pos=pos, dims=dims, $
min_population=min_population, $
class_ptr=class_ptr, $
/all_neighbors, out_name=out_name
;
; Exit ENVI
;
envi_batch_exit
end

See Also
CLASS_CS_DOIT
CLASS_MAJORITY_DOIT

ENVI_SEGMENT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

447

ENVI_SELECT
This procedure provides the standard ENVI File Selection dialog for selecting data
files open in the current ENVI session. In its default form the dialog allows the
selection of a file or band with an option for spatial and spectral subsetting. However,
the dialog has a number of keywords that allow precise control over the options
allowed during the data selection.
Once the dialog is started, the remaining ENVI session is modal until the OK or
Cancel button is selected. If the OK button is selected the value returned in the FID
is the file ID of the selected data. This FID value is used in subsequent ENVI routines
and is the link to the selected file.

Figure 22-4: A File Selection Dialog by File

ENVI Reference Guide

ENVI_SELECT

448

Chapter 2: ENVI Routines

Figure 22-5: A File Selection Dialog by Band

Syntax
ENVI_SELECT

Keywords
BAND_ONLY (optional)
Set this optional keyword to disable selection of files using the Input File toggle
button and to only allow band selection.

DIMS (optional)
Use this optional keyword to specify a named variable that will contain a fiveelement array holding the data dimensions.The elements are defined as follows:

ENVI_SELECT

DIMS[0]: a pointer to the ROI (set to -1 if no ROI is selected).

DIMS[1]: the starting X coordinate.

DIMS[2]: the ending X coordinate.

ENVI Reference Guide

Chapter 2: ENVI Routines

DIMS[3]: the starting Y coordinate.

DIMS[4]: the ending Y coordinate.

449

FID (optional)
Use this keyword to specify a named variable that will contain the file ID of the
selected file when the OK button is selected. If FID[0] = -1, the Cancel button was
selected and the user should take the appropriate action.

FILE_ONLY (optional)
Set this optional keyword to disable selection of single bands using the Input band
toggle button and only allow file selection.

FILE_TYPE (optional)
Set this optional keyword to an integer value specifying the allowable file type. Only
files with matching types are considered valid. See ENVI_FILE_TYPE on
page 301 for details on how to determine the integer value of a file type.

MASK (optional)
Set this optional keyword to allow selection of a mask.

M_FID (optional)
Use this optional keyword to specify a named variable that will contain the file ID of
the selected mask file. To enable mask selection the keyword MASK must be set.

M_POS (optional)
Use this optional keyword to specify a named variable that will contain the band
position of the selected mask. To enable mask selection the keyword MASK must be
set.

NO_DIMS (optional)
Set this optional keyword to disable spatial subsetting.

NO_SPEC (optional)
Set this optional keyword to disable spectral subsetting.

ENVI Reference Guide

ENVI_SELECT

450

Chapter 2: ENVI Routines

POS (optional)
Use this optional keyword to specify a named variable that will contain an array
holding the bands selected.

ROI (optional)
Set this optional keyword to allow Region of Interest (ROI) subsetting. If selection is
subset by ROI then DIMS[0] contains the roi pointer.

TITLE (optional)
Use this optional keyword to specify the string used in the title bar of the File
Selection dialog window. Enter the title enclosed in single quotes.

Example
This example shows how to select a file or band and return the FID, DIMS, and POS
information. This is typically the simplest use of ENVI _SELECT. In addition, if the
Cancel button is selected (e.g., FID[0] = -1), then return from the current user
procedure.
ENVI_SELECT, fid=fid,dims=dims,pos=pos
if (fid[0] eq -1) then return

The following example will allow selection of a single classification band with no
spatial subset. The FILE_TYPE keyword set to Classification only allows selection
of a classification band and issues a warning on attempts to select non-classification
data. The FILE_TYPE keyword can be used with any of the 20+ types and not just
classification images. The BAND_ONLY and NO_DIMS keywords control the
additional limitation of only allowing a single band with no spatial subset. The
returned file ID and band number are retrieved with the FID and POS keywords,
respectively. In addition, if the Cancel button is selected (e.g., FID[0] = -1), then
return from the current user procedure. Finally, use the TITLE keyword to set the
dialog title bar to Classification Input File.
;
; First get the integer file type value using ENVI_FILE_TYPE
;
ftype = ENVI_FILE_TYPE(Classification)
;
; Now prompt the user for the classification band
;

ENVI_SELECT

ENVI Reference Guide

Chapter 2: ENVI Routines

451

ENVI_SELECT, fid=fid, pos=pos, /band_only, $


/no_dims, file_type=ftype, $
title=Classification Input File
if (fid[0] eq -1) then return

Notes
If fid(0) = -1, the cancel button was selected and the user should take the appropriate
action.

See Also
ENVI_OPEN_FILE
ENVI_PICKFILE

ENVI Reference Guide

ENVI_SELECT

452

Chapter 2: ENVI Routines

ENVI_SENSOR_TYPE
Use this function to get a string or integer value of a particular sensor type. Inputting
an integer value returns the string sensor type and likewise inputting a string sensor
type returns the corresponding integer value. The predefined sensor types are shown
below and the user can also add sensor types to the file sensor.txt in the menu
directory of the release tree.

Syntax
Result = ENVI_SENSOR_TYPE(Sensor_type)

Arguments
Sensor_type
Sensor_type can be either an integer or a string. If Sensor_type is an integer, the
function returns the string-format description of the sensor type specified. If
Sensor_type is a string, the function returns the integer code describing the sensor
type specified.
The following table shows the available sensor types. String sensor type descriptions
are case-sensitive and may contain spaces.
Sensor Type

Integer

Sensor Type

Integer

AATSR

IRS Pan

23

ADAR

IRS WIFS

24

ADEOS

JERS-1

25

ADRG

Landsat MSS

26

Air Photo

Landsat TM

27

AIRSAR

MAS

28

AISA

MASTER

29

ASAR

MERIS

30

ASTER

MIVIS

31

Table 22-5: ENVI Sensor Types


ENVI_SENSOR_TYPE

ENVI Reference Guide

Chapter 2: ENVI Routines

Sensor Type

453

Integer

Sensor Type

Integer

AVHRR

MODIS

32

AVIRIS

10

MOMS-02

33

CASI

11

RADARSAT

34

DMSP

12

Scanned Image

35

QuickBird

13

SEAWIFS

36

EROS

14

SEBASS

37

ERS-1

15

SIR-C

38

ERS-2

16

SPIN-2

39

GER63

17

SPOT

40

GEOSCAN

18

TIMS

41

HYDICE

19

TMS

42

Hyperion

20

TRWIS III

43

IKONOS

21

USGS DEM

44

IRS LISSIII

22

X-SAR

45

Table 22-5: ENVI Sensor Types


Note
Because additional sensor types are likely to be added in future releases of ENVI, it
is strongly recommended that you use string descriptors rather than integer
descriptors when referencing sensor types. See the example below for details.

Keywords
None

ENVI Reference Guide

ENVI_SENSOR_TYPE

454

Chapter 2: ENVI Routines

Example
The following example prints the sensor type string for the file associated with the
file ID FID. The first command stores the integer file type descriptor in the variable
SENSOR_TYPE:
envi_file_query, fid, sensor_type=sensor_type

The next line stores the string sensor type descriptor in the variable type_string:
type_string = envi_sensor_type(sensor_type)
print, type_string

The following example enters the array DATA into ENVI and sets the sensor type to
SPOT. The first line gets the integer sensor type for SPOT. The second line enters the
data and sets the SENSOR_TYPE corresponding to SPOT.
sensor_type = envi_sensor_type(SPOT)
envi_enter_data, DATA, sensor_type=sensor_type

See Also
ENVI_FILE_QUERY
ENVI_FILE_TYPE

ENVI_SENSOR_TYPE

ENVI Reference Guide

Chapter 2: ENVI Routines

455

ENVI_SET_INHERITANCE
Use this routine to return the ENVI inheritance structure. ENVI inheritance allows a
newly created ENVI file to automatically inherit properties from the original data.
The result of this function is used to set the INHERIT keyword to the
ENVI_SETUP_HEAD or ENVI_ENTER_DATA routines. Inheritance has three
options, FULL, SPATIAL or SPECTRAL. The FULL keyword inherits all spatial,
spectral and other information from the original file. In addition, the FULL keyword
can be used with the NO_SPATIAL keyword to inhibit inheritance of spatial
information. The SPATIAL keyword inherits only the spatial information from the
original file and the SPECTRAL keyword inherits only the spectral information from
the original file. See the keyword definitions for more information.
This routine should be used instead of directly accessing the inherit structure.

Syntax
Result = ENVI_SET_INHERITANCE (Fid, Dims [,Pos])

Arguments
Fid
Use this argument to specify the file ID to inherit information from. The value of FID
should be the file ID of the original data used to generate the new output image. This
is the value returned from the keyword R_FID in the ENVI_OPEN_FILE procedure
or the FID keyword to ENVI_SELECT. FID is a long integer with a value greater
than zero. An invalid file ID is specified as -1.

Dims
Use this argument to specify the spatial dimensions to inherit information from. The
value of Dims should be the values used to compute the new output bands. Dims is a
five-element array of long integers with the following definitions:

Dims[0]: Unused for this function, set to -1.

Dims[1]: The starting X pixel. (The first pixel is number zero.)

Dims[2]: The ending X pixel.

Dims[3]: The starting Y pixel. (The first pixel is number zero.)

Dims[4]: The ending Y pixel.

ENVI Reference Guide

ENVI_SET_INHERITANCE

456

Chapter 2: ENVI Routines

POS (optional)
Use this argument to specify an array of band positions, indicating the band numbers
to inherit information from. The bands specified by POS should be the bands used to
generate the new output image. POS is an array of long integers, ranging from zero to
the number of bands-1. The default is to set Pos=[0], the first band.

Keywords
FULL (optional)
Set this optional keyword to enable full inheritance. The FULL keyword will inherit
wavelengths, full width half-max, bad bands list, sensor type, file type, map
information, pixel size, XY starting pixel, classification information, spectral library
information, Z-plot range, geographic points, default stretch, and default RGB bands.
If the FULL keyword is set then the SPATIAL or SPECTRAL keywords are not
needed.

NO_SPATIAL (optional)
Set this optional keyword to inhibit spatial inheritance. The NO_SPATIAL keyword
will turn off inheritance of map information, pixel size, XY starting pixel, and
geographic points. The NO_SPATIAL keyword should only be used in conjunction
with the FULL keyword.

SPATIAL (optional)
Set this optional keyword to enable spatial inheritance. The SPATIAL keyword will
inherit map information, pixel size, XY starting pixel, and geographic points.

SPECTRAL (optional)
Set this optional keyword to enable spectral inheritance. The SPECTRAL keyword
will inherit wavelengths, full width half-max, bad bands list, and default RGB bands.

Example
The following example will create an inherit structure able to inherit all the
information from the original file. This example assumes that FID, DIMS and POS
are previously set.
inherit = envi_set_inheritance(fid, dims, pos, /full)

ENVI_SET_INHERITANCE

ENVI Reference Guide

Chapter 2: ENVI Routines

457

The following example will create an inherit structure able to inherit only the spectral
information from the original file. This example assumes that FID, DIMS and POS
are previously set.
inherit = envi_set_inheritance(fid, dims, pos, /spectral)

See Also
ENVI_ENTER_DATA
ENVI_SETUP_HEAD

ENVI Reference Guide

ENVI_SET_INHERITANCE

458

Chapter 2: ENVI Routines

ENVI_SETUP_HEAD
Use this routine to create the ENVI header information for a disk file. In order for
disk files to be used in ENVI they need the associated ENVI header information. The
required keywords (DATA_TYPE, INTERLEAVE, NB, NL, NS, OFFSET) define
the most primitive set of information needed to access the data in the file. The
optional keywords allow the definition of more specific file information.
In memory, data files do not need to call ENVI_SETUP_HEAD instead they use
ENVI_ENTER_DATA.

Syntax
ENVI_SETUP_HEAD

Keywords
BBL (optional)
Use this optional keyword to specify an array of ones and zeros representing the good
and bad bands. The number of elements in BBL must be equal to the number of bands
in the image. A one represents a good band and a zero represents a bad band.

BNAMES (optional)
Use this optional keyword to specify the band names assigned to the data. BNAMES
is a string array of number-of-bands band names. The default band names are [band
1, band 2, etc.]

BYTE_ORDER (optional)
Use this optional keyword to specify a named variable that will contain a flag
indicating the byte order of the data. Set byte order to 1 for big-endian data (i.e., data
generated on SUN, SGI, PowerMac. etc.) and to 0 for little-endian data i.e.,. data
generated on PC x86). The default is the byte order of the machine.

CLASS_NAMES
Use this keyword to specify a string array of class names for classification images.
The first element (class 0) is the Unclassified class. CLASS_NAMES should only
be specified if the result is a classification image. CLASS_NAMES is a required
keyword if the file type is equal to 'classification', otherwise, it is optional.

ENVI_SETUP_HEAD

ENVI Reference Guide

Chapter 2: ENVI Routines

459

DATA_GAINS (optional)
Use this optional keyword to specify a named variable to contain an array of gains for
each band in the data set. DATA_GAINS is an array of values, one for each band.
DATA_GAINS can be used in conjunction with DATA_OFFSETS in ENVIs General
Purpose Utility - Apply Gain and Offset.

DATA_IGNORE_VALUE (optional)
Use this optional keyword to specify a named variable to contain a scalar number
representing the data value to ignore in the data set. If set DATA_IGNORE_VALUE
is the same type as the input data set and an undefined ignore value is represented by
the double precision number 1e-34. Currently, this value is used only in user-written
ENVI code.

DATA_OFFSETS (optional)
Use this optional keyword to specify a named variable to contain an array of offsets
for each band in the data set. DATA_OFFSETS is an array of values, one for each
band. DATA_OFFSETS can be used in conjunction with DATA_GAINS in ENVIs
General Purpose Utility - Apply Gain and Offset.

DATA_TYPE
Use this keyword to specify the IDL data type of the file, using the following IDL
convention:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

ENVI Reference Guide

ENVI_SETUP_HEAD

460

Chapter 2: ENVI Routines

DEF_BANDS (optional)
A 1 or 3 element array containing which bands to load by default upon opening in
ENVI...if 1 elements, then ENVI will load a gray scale. if 3 elements, ENVI will load
an RGB... The values are 0 based so to load bands 4,3,2 of a 7 band image, set
DEF_BANDS=[3,2,1].

DEF_STRETCH (optional)
Use this optional keyword to specify the default stretch information. Set
DEF_STRETCH equal to the value returned from
ENVI_DEFAULT_STRETCH_CREATE.

DESCRIP (optional)
Use this optional keyword to specify a text description of the data or of the type of
processing performed.

FILE_TYPE (optional)
Use this optional keyword to specify a named variable that will contain the integer
file type value. See ENVI_FILE_TYPE on page 301 for details on how to
determine the integer file type value.

FNAME
Use this keyword to specify the file name (and path) of the disk file. FNAME is a
string variable that ENVI will use to open the file for reading.

FUNC_COMPLEX (optional)
Set this optional keyword to indicate the Complex Lookup Function to determine
which image to display for complex data. This keyword should be set to one of the
following:
0 Power (natural log of the magnitude)
1 Magnitude (square root of sum of the squares of the real and imaginary)
2 Real (real portion of number)
3 Imaginary (imaginary portion)
4 Phase (arc tangent of imaginary divided by real)
The default image is Power. Only set this keyword if the IDL data type of the image
is 6=complex (2 x 32-bit) or 9=double-precision complex (2 x 64-bit).

ENVI_SETUP_HEAD

ENVI Reference Guide

Chapter 2: ENVI Routines

461

FWHM (optional)
Use this optional keyword to specify an array of full-width-half-maximum responses
for each band. The number of elements in this array is equal to the number of bands
in the image.

GEO_POINTS (optional)
Use this optional keyword to specify a 16-element double array of geographic
coordinates for the four corners. The array is comprised of four groups of X and Y
pixel locations and the corresponding latitude and longitude values (negative for
South latitude and negative for West longitude). The four groups of points represent
the four corners: upper left, upper right, lower left, lower right. The array is defined
as follows
GEO_POINTS[0:3] -> [X , Y, LAT, LON] - upper left
GEO_POINTS[4:7] -> [X , Y, LAT, LON] - upper right
GEO_POINTS[8:11] -> [X , Y, LAT, LON] - lower left
GEO_POINTS[12:15] -> [X , Y, LAT, LON] - lower right

INFO (optional)
Use this optional keyword to specify user defined information. INFO is used to store
information which can be passed to users spatial and spectral readers. INFO is
retrieved from ENVI_FILE_QUERY using the keyword H_INFO which is a handle
to the data. Use HANDLE_VALUE and the handle H_INFO to retrieve the data
INFO.

INHERIT (optional)
Use this optional keyword to specify the file inheritance. Set INHERIT equal to the
value returned from ENVI_SET_INHERITANCE.

INTERLEAVE
Use this keyword to specify the files interleave type. Set to zero if the file is in BSQ
format, to one if BIL format, and to two if BIP format.

LOOKUP (optional)
Use this optional keyword to specify a long array of class RGB values. The
LOOKUP array contains one RGB triple for each class specified with the
NUM_CLASSES keyword. The dimensions of the array are [3,NUM_CLASSES]
and the RGB triplet is ordered [R,G,B]. LOOKUP must be set when entering a
classification image.

ENVI Reference Guide

ENVI_SETUP_HEAD

462

Chapter 2: ENVI Routines

MAP_INFO (optional)
Use this optional keyword to specify map information. Set MAP_INFO equal to the
structure returned from ENVI_MAP_INFO_CREATE.

NB
Use this keyword to specify the number of bands in the file.

NL
Use this keyword to specify a the number of lines in the file.

NS
Use this keyword to specify the number of samples in the file.

NUM_CLASSES (optional)
Use this optional keyword to specify the number of classes for classification files.
Remember to include the Unclassified class (class 0) in the number of classes. This
keyword should only be specified for classification files.

OFFSET
Use this keyword to specify the offset (in bytes) to the start of the data in the file.

OPEN (optional)
Set this optional keyword to add the file to the Available Bands List. The default is
not to add the file to the Available Bands List.

PIXEL_SIZE (optional)
Use this optional keyword to specify the pixel size of images that are not
georeferenced. PIXEL_SIZE is a floating point array of two specifying the X and Y
pixel size respectively.

POINTER_INFO (optional)
If the FILE_TYPE keyword is set to HDF scientific data (FILE_TYPE = 'HDF SD'),
use this optional keyword to specify an anonymous structure containing data_set
and ndims fields. The data_set field is a long integer indicating HDF SD dataset
index in the HDF file. The ndims field is a long integer indicating the number of
dimensions of dataset specified with the data_set field.

ENVI_SETUP_HEAD

ENVI Reference Guide

Chapter 2: ENVI Routines

463

R_FID (optional)
Use this optional keyword to specify a named variable that will hold the file ID for
files that are added to the Available Bands List. The file ID is only set when the
OPEN keyword is also set.

READ_PROCEDURE (optional)
Use this optional keyword to specify a named variable that will contain a string array
of the procedure names for the spatial and spectral readers, respectively.

REFLECTANCE_SCALE_FACTOR (optional)
Use this optional keyword to specify a named variable to contain a single scalar
number used to convert the input data into reflectance. For example,
REFLECTANCE_SCALE_FACTOR would be used to convert integer scaled
reflectance data into their floating point [0,1] reflectance values.

SENSOR_TYPE (optional)
Use this optional keyword to specify an integer value related to the sensor type. See
ENVI_SENSOR_TYPE on page 452 for details on how to determine the integer
sensor type value.

SPEC_NAMES (optional)
Use this optional keyword to specify a named variable that will contain a string array
of spectral library names. The keyword SPEC_NAMES should only be set for a
spectral library file.

UNITS (optional)
Use this optional keyword to specify the PIXEL_SIZE units for images that are not
georeferenced. UNITS is an integer value returned from
ENVI_TRANSLATE_PROJECTION_UNITS. Georeferenced images do not use this
value instead they use the pixel size and units contained in the map information
structure.

WAVELENGTH_UNIT (optional)
Use this optional keyword to specify a named variable to contain a value indicating
the wavelength units. The valid values are one of the following:

0 Micrometers

1 Nanometers

ENVI Reference Guide

ENVI_SETUP_HEAD

464

Chapter 2: ENVI Routines

2 Wavenumber

3 GHz

4 MHz

5 Index

6 Unknown

WL (optional)
Use this optional keyword to specify an array of wavelength values. The number of
elements in this array is equal to the number of bands.

WRITE (optional)
Set this optional keyword to write an output header to disk. The default is to not write
an output header. It is possible (and valid) to add a file to the Available Bands List
(OPEN keyword) and not write the header file to disk. You should always set the
WRITE keyword for files that you wish to open in a later ENVI session.

XSTART (optional)
Use this optional keyword to specify the X starting sample for the first pixel in the
file. The default is zero. XSTART in conjunction with YSTART are used to preserve
the spatial reference for subsetted files. When processing a file the XSTART of the
output file is typically set to the XSTART of the input file plus the value of DIMS[1]
(the starting sample).

YSTART (optional)
Use this optional keyword to specify the Y starting line for the first pixel in the file.
The default is zero. YSTART in conjunction with XSTART are used to preserve the
spatial reference for subsetted files. When processing a file the YSTART of the
output file is typically set to the YSTART of the input file plus the value of DIMS[3]
(the starting line).

ZPLOT_AVERAGE (optional)
Use this optional keyword to specify a two-element long array for the X and Y
window size (in pixels) for the Z-Profile. The window size must be 1 or greater.
The Z-Profile is formed from the average of the profiles within the specified window.
The default window size is [1,1].

ENVI_SETUP_HEAD

ENVI Reference Guide

Chapter 2: ENVI Routines

465

ZPLOT_TITLES (optional)
Use this optional keyword to specify a two element string array for the X and Y plot
titles. The default X title is Band Number for images with no wavelength
information and Wavelength for images with wavelength information. The default
Y axis title is Value.

ZRANGE (optional)
Use this optional keyword to specify a two dimensional array for the lower and upper
spectral plot range.

Example
The following example will generate a 256x256 three band BSQ byte ramp image
using the function BINDGEN. This image will be saved to disk using the filename
test.img. Once the file is saved to disk ENVI_SETUP_HEAD will be used to write
an ENVI header and add the image to the Available Bands List. This is one of the
simplest uses of ENVI_SETUP_HEAD.
; Create the image array
;
data = BINDGEN(256,256,3)
;
; Open the output file and write
; the image to disk
;
fname = test.img
openw, unit, fname, /get_lun
writeu, unit, data
free_lun, unit
;
; Write the ENVI header and
; add the image to the Available
; Bands List
;
ENVI_SETUP_HEAD, fname=fname, $
ns=256, nl=256, nb=3, $
interleave=0, data_type=1, $
offset=0, /write, /open

The next example will create two classes (plus the Unclassified class) from a single
band ramp image, save the file to disk, and enter the resulting classification image
into ENVI. The Unclassified class will be Black [0,0,0], the first class will be Red
[255,0,0] and the second class will be Yellow [255,255,0]. The class names will be

ENVI Reference Guide

ENVI_SETUP_HEAD

466

Chapter 2: ENVI Routines

Unclassified, Red, and Yellow. The classification image will have the description
Example Classification Image and the band name Ramp Classification.
; Create a 2D ramp and then classify all values
; from 20 to 100 in the first class (classification
; data value equal to one) and classify all values
; from 101 to 220 into the second class
; (classification data value equal to two)
;
data = BINDGEN(256,256)
class = BYTE((data ge 20 and data le 100) + $
2B * (data ge 101 and data le 220))
;
; Save the classification image to disk
;
fname = test.img
openw, unit, fname, /get_lun
writeu, unit, class
free_lun, unit
;
; Create the classification information
;
class_names = [Unclassified,Red,Yellow]
lookup = [[0,0,0],[255,0,0],[255,255,0]]
bnames = [Ramp Classification]
descrip = Example Classification Image
file_type = ENVI_FILE_TYPE(ENVI Classification)
;
; Write the ENVI header and add the image
; to the Available Bands List
;
ENVI_SETUP_HEAD, fname=fname, $
ns=256, nl=256, nb=1, $
interleave=0, data_type=1, $
offset=0, num_classes=3, $
class_names=class_names, $
lookup=lookup, file_type=file_type, $
bnames=bnames, descrip=descrip, $
/write, /open

The next example takes a ramp image and assign a geographic projection to the
image with the upper left corner at 15 degrees south, 48 degrees west, and an X and Y
pixel size of one arc second. The map projection will be created using
ENVI_MAP_INFO_CREATE and the resulting structure will use the MAP_INFO
keyword when entering the data into ENVI.
; First create the ramp image. The ramp image
; would actually be replaced by a real
; georeferenced image.

ENVI_SETUP_HEAD

ENVI Reference Guide

Chapter 2: ENVI Routines

467

;
data = BINDGEN(256,256)
;
; Open the output file and write
; the image to disk
;
fname = test.img
openw, unit, fname, /get_lun
writeu, unit, data
free_lun, unit
;
; Create the items used for the projection
;
mc = [.5D,.5, -48,-15]
ps = [1D/3600, 1D/3600]
units = ENVI_TRANSLATE_PROJECTION_UNITS(Degrees)
map_info = ENVI_MAP_INFO_CREATE(/geographic, $
mc=mc, ps=ps, units=units)
;
; Enter the data into ENVI
;
ENVI_SETUP_HEAD, fname=fname, $
ns=256, nl=256, nb=1, $
interleave=0, data_type=1, $
offset=0, map_info=map_info, $
/write, /open

See Also
ENVI_ENTER_DATA

ENVI Reference Guide

ENVI_SETUP_HEAD

468

Chapter 2: ENVI Routines

ENVI_SMACC_DOIT
The ENVI_SMACC_DOIT procedure performs sequential maximum angle convex
cone (SMACC) processing on an input file. This routine is designed for use with
previously calibrated hyperspectral data or multispectral data.
This procedure applies the SMACC process to a radiance or reflectance calibrated
hyperspectral image, and returns the following outputs:

A spectral library of derived endmembers

An abundance image with N_ENDMEMBERS number of bands. This result is


an optional output.

Regions of interest (ROIs) representing the set of endmembers. This result is


an optional output.

Syntax
ENVI_DOIT, 'ENVI_SMACC_DOIT' [, /ABUND_IN_MEMORY]
[, ABUND_NAME=string, ABUND_R_FID=variable] [, COALESCE=value] ,
DIMS=array, FID=fileID, /IN_MEMORY | OUT_NAME=string
[, M_FID=fileID, M_POS=integer], METHOD={0 | 1 | 2},
N_ENDMEMBERS=integer [, PLOT_FLAG=bitwise operator], POS=array,
R_FID=variable [, ROI_NAME=string] [, THRESH=value]

Arguments
None

Keywords
ABUND_IN_MEMORY (optional)
Set this optional keyword to indicate an abundance image should be generated and
saved in memory only. If the ABUND_IN_MEMORY keyword is not set and a
filename is specified for the ABUND_NAME keyword, the abundance image is
generated and stored on disk.

ABUND_NAME (optional)
Use this optional keyword to specify a filename for the abundance image output. If a
filename is specified for this keyword, an abundance image is generated and saved to

ENVI_SMACC_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

469

a file with the specified name. If the ABUND_NAME keyword is not used and the
ABUND_IN_MEMORY keyword is set, an abundance image is generated and stored
in memory.

ABUND_R_FID (optional)
Set this optional keyword to a named variable to contain the file ID of the output
abundance image. An abundance image is only generated if either the
ABUND_IN_MEMORY or ABUND_NAME keyword is specified. If neither
keyword is specified, an abundance image is not generated and a value of 1 is
returned for the ABUND_R_FID keyword.

COALESCE (optional)
Use this keyword to specify the maximum SAM (Spectral Angle Mapper) threshold
value above which endmember spectra are considered unique. The default value is
0.0.

DIMS
Use this optional keyword to specify the spatial dimensions on which to perform the
operation. The DIMS keyword is set to a five-element array of long integers with the
following definitions:
Array Element

Description

DIMS[0]

Unused for this function, set to 1

DIMS[1]

The starting X pixel.


Note - The first pixel is number zero.

DIMS[2]

The ending X pixel.

DIMS[3]

The starting Y pixel.


Note - The first pixel is number zero.

DIMS[4]

ENVI Reference Guide

The ending Y pixel.

ENVI_SMACC_DOIT

470

Chapter 2: ENVI Routines

FID
Use this keyword to specify the file ID for the calibrated input file. This ID is the
value returned from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is
a long integer with a value greater than zero. An invalid file ID is specified as 1.

IN_MEMORY
Set this keyword to store the spectral library output in memory. If IN_MEMORY is
not set, output is stored on disk by default.

M_FID (optional)
Use this optional keyword to specify the file ID for a mask file. This ID is the value
returned from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a
long integer with a value greater than zero. An invalid file ID is specified as 1.

M_POS (optional)
Use this keyword to specify the band position of the mask band. M_POS is a single
long value greater than or equal to zero. This keyword must be used if the M_FID
keyword is specified.

METHOD (optional)
Use this optional keyword to specify an integer value that indicates the unmixing
constraint for the SMACC method. The following table shows the integer values that
represent each possible constraint and their related conditions.

ENVI_SMACC_DOIT

Value

Constraint

Condition

Positivity Only (default)

Inputs should be calibrated to


reflectance.

Sum to Unity or Less

Inputs should be calibrated to


reflectance.

Sum to Unity

Inputs should be calibrated to


radiance or thermal IR
emissivity.

ENVI Reference Guide

Chapter 2: ENVI Routines

471

All of these options also impose a positivity constraint. In the unmixing model,
negative fractional abundances are not allowed and are set to zero.
If Positivity Only (METHOD = 0) or Sum to Unity or Less (METHOD = 1) are
specified, the SMACC method begins with an endmember value of 1.0 (total
reflectance). If Sum to Unity (METHOD = 2) is specified, the SMACC method
begins with an endmember value of 0.0 (zero radiance). Regardless, both of these
endmembers are presumed to lie at an extreme point (or even outside) of a plausible
convex hull. This point becomes a reasonable baseline for the SMACC method.

N_ENDMEMBERS
Use this keyword to specify the maximum number of desired endmembers.

OUT_NAME
Use this keyword to specify an output file name for the resulting spectral library. If
the keyword IN_MEMORY is set, this keyword is not needed.

PLOT_FLAG (optional)
Use this keyword to specify an integer value that determines which resulting plot
window is provided. The SMACC process can produce either an endmember plot
window, a residual error plot window, or both. These plot windows are not displayed
by default. To display either of these plot windows, use the values shown in the
following table.

ENVI Reference Guide

Value

Description

The endmember and residual error plots


are not displayed, which is the default
setting.

The endmember plot is displayed.

The residual error plot is displayed.

Both plot windows are displayed.

ENVI_SMACC_DOIT

472

Chapter 2: ENVI Routines

POS
Use this keyword to specify an array of band positions indicating the band numbers
on which to perform the operation. POS is an array of long integers that range from
zero to Nb 1, where Nb is the number of bands available. If this keyword is not
specified, all of the bands are used.

R_FID
Use this keyword to specify a named variable to contain the file ID for the resulting
spectral library. This file ID can be used to access this library.

ROI_NAME (optional)
Use this optional keyword to indicate ROIs (Regions of Interest) should be generated
and to specify the name of the file to contain these ROIs. The generated ROIs contain
the endmember pixels. If this keyword is not set, the ROIs are not generated.

THRESH (optional)
Use this optional keyword to specify the residual RMS error threshold at which the
SMACC process is terminated.
Note
Data units should be considered when choosing the tolerance. For example, RMS
errors for reflectance units should be lower than for radiance units.

Examples
The following example uses the cup95eff.int file in the data directory. The
SMACC process is used to create a spectral library of 10 endmembers from the data
in this file.
PRO SMACCExample
; This example procedure uses the ENVI_SMACC_DOIT procedure
; (the Sequential Maximum Angle Convex Cone algorithm) to derive
; a spectral library of endmembers for the data in the
; "cup95eff.int" image file.
; Find the input image file and determine its file ID.
cupriteFile = ENVI_PICKFILE(FILTER = *.int, $
TITLE = Find the "cup95eff.int" File)
IF (cupriteFile EQ ) THEN RETURN
ENVI_OPEN_FILE, cupriteFile, R_FID = cupriteFID
ENVI_FILE_QUERY, cupriteFID, NB = cupriteNB, NS = cupriteNS, $

ENVI_SMACC_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

473

NL = cupriteNL, WL = cupriteWLs
cupriteDims = [-1, 0, cupriteNS - 1, 0, cupriteNL - 1]
cupriteBandPos = LINDGEN(cupriteNB)
; Specify the number of resulting endmembers.
numEndmembers = 10
; Apply the SMACC process to the input data.
ENVI_DOIT, ENVI_SMACC_DOIT, FID = cupriteFID, $
DIMS = cupriteDims, $
POS = cupriteBandPos, OUT_NAME = smaccExample.sli, $
N_ENDMEMBERS = numEndmembers, R_FID = libFID
; Access and plot the resulting spectral library.
ENVI_FILE_QUERY, libFID, NS = libNS, NL = libNL, WL = libWLs
libDims = [-1, 0, libNS - 1, 0, libNL - 1]
libData = ENVI_GET_DATA(FID = libFID, DIMS = libDims, POS = 0)
ENVI_PLOT_DATA, libWLs, libData, XTITLE = Wavelength, $
YTITLE = Value
END

This example procedure produces a plot of the 10 endmember spectra and a file
(smaccExample.sli) containing the resulting spectral library.

ENVI Reference Guide

ENVI_SMACC_DOIT

474

Chapter 2: ENVI Routines

ENVI_SPECTRAL_RESAMPLING_DOIT
The ENVI_SPECTRAL_RESAMPLING_DOIT procedure spectrally resamples
image or spectral library files. Resampled spectral libraries are added to the Available
Bands List.

Syntax
ENVI_DOIT, ENVI_SPECTRAL_RESAMPLING_DOIT [, BAD_VALUE=value]
[, /COMPRESSION], DIMS=array, FID=fileID , /IN_MEMORY |
OUT_NAME=string [, OUT_DT=integer] [, OUT_FWHM=array],
OUT_WAVELENGTH_UNITS=integer, OUT_WL=array
[, OUT_BNAME=string array], POS=array [, R_FID=fileID]

Arguments
None

Keywords
BAD_VALUE (optional)
Use this optional keyword to specify a value to use for spectra that fall outside the
input wavelength range. In this case, no extrapolation will be performed. All spectra
values equal to BAD_VALUE are considered bad values. BAD_VALUE is a single
number.

COMPRESSION (optional)
Set this optional keyword to write the file using the standard GZIP format. IDLs
GZIP support is based on the freely available ZLIB library version 1.1.3 by Mark
Adler and Jean-loup Gailly. This means that compressed files are 100% compatible
with the widely available gzip and gunzip programs.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

ENVI_SPECTRAL_RESAMPLING_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

475

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. The file ID value is obtained
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired. Default
output band names is Resample prepended to input band names.

OUT_DT (optional)
Set this keyword to indicate the IDL data type of the output data using the following
IDL convention:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

The default output type is the data type of the input file.

ENVI Reference Guide

ENVI_SPECTRAL_RESAMPLING_DOIT

476

Chapter 2: ENVI Routines

OUT_FWHM
Use this optional keyword to specify a floating point array of full-width-halfmaximum responses for each output band. The number of elements in this array is
equal to the number of output bands.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OUT_WAVELENGTH_UNITS
Use this keyword to specify an integer value representing the units used for the
values of the OUT_WL array. The following table shows the integer values that
represent each possible unit:
Value

Wavelength Unit

Micrometers

Nanometers

Wavenumber

GHz

MHz

Index

Unknown

OUT_WL
Use this keyword to specify an array of wavelengths to resample to.

ENVI_SPECTRAL_RESAMPLING_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

477

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

ENVI Reference Guide

ENVI_SPECTRAL_RESAMPLING_DOIT

478

Chapter 2: ENVI Routines

ENVI_STATS_DOIT
Use ENVI_STATS_DOIT to calculate statistics of a data file and optionally display
the results or write the results to a file. The calculated statistics include; covariance,
data maximum, data minimum, eigenvalues, eigenvectors, histograms, mean, and
standard deviation.

Syntax
ENVI_DOIT, ENVI_STATS_DOIT

Keywords
COMP_FLAG
Set this keyword equal to a bit value indicating the computations to perform. The bit
values are logically ORd together to perform the requested calculations. The first bit
is ignored. Additional bits must be set to calculate histograms and to calculate
convariance, eigenvalues, and eigenvectors. The definition of the bits used in
COMP_FLAG are as follows:

bit 0 not used.

bit 1 enables the calculation of histograms.

bit 2 enables the calculation of covariance, eigenvalues and eigenvectors.

bit 3 to 15 not used.

If only maximum, minimum, mean, and standard deviation are desired then
COMP_FLAG should be set to one, otherwise set COMP_FLAG based on the need
to compute histograms and covariance, eigenvalues, and eigenvectors. For example,
to calculate all the available statistics (maximum, minimum, mean, standard
deviation, histograms, covariance, eigenvalues, and eigenvectors) set
COMP_FLAG=7.

COV (optional)
Use this optional keyword to specify a named variable that will contain the returned
covariance matrix. You must set bit 2 in COMP_FLAG (i.e. COMP_FLAG=4) to
generate the covariance matrix.

ENVI_STATS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

479

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: A pointer to the region of interest. Set to -1 for non ROI items.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

DMAX (optional)
Use this optional keyword to specify a named variable that will contain the array of
data maximums, one for each band position.

DMIN (optional)
Use this optional keyword to specify a named variable that will contain the array of
data minimums, one for each band position.

EVAL (optional)
Use this optional keyword to specify a named variable that will contain the
eigenvalues. You must set bit 2 in COMP_FLAG (i.e. COMP_FLAG=4) to generate
the eigenvalues.

EVEC (optional)
Use this optional keyword to specify a named variable that will contain the
eigenvector. You must set bit 2 in COMP_FLAG (i.e. COMP_FLAG=4) to generate
the eigenvectors.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

ENVI Reference Guide

ENVI_STATS_DOIT

480

Chapter 2: ENVI Routines

HIST (optional)
Use this optional keyword to specify a named variable that will contain the histogram
array. You must set bit 1 in COMP_FLAG (i.e. COMP_FLAG=2) to generate the
histogram output.

M_FID
Use this keyword to specify the file ID for the mask file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

M_POS
Use this keyword to specify the band position of the mask band. M_POS is a single
long value greater than or equal to zero.

MEAN (optional)
Use this optional keyword to specify a named variable that will contain the array of
data means, one for each band position.

OUTPUT_IMAGE (optional)
Set this optional keyword to save the covariance values to an image. The R_FID
keyword can be used to access the file ID of the resulting covariance image.
Note
The covariance must be calculated (COMP_FLAG = 4 or greater) to generate this
output image. If the COMP_FLAG keyword is not set to 4 or greater, the
OUTPUT_IMAGE keyword is ignored.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

ENVI_STATS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

481

PREC (optional)
Use this keyword to specify the format for numbers printed in statistics reports.
PREC is a two-element array of long integers with the following definitions:

PREC[0]: Set to the desired number of digits to be printed after the decimal
point.

PREC[1]: Set to zero (0) to specify fixed-point notation or set to one (1) to
specify scientific (exponential) notation.

R_FID (optional)
Use this keyword to specify a named variable that will hold the file ID for the
covariance image. The proper bit must be set in PLOT_FLAG in order to save the
covariance image.

REP_NAME (optional)
Use this optional keyword to specify the output report filename.

STA_NAME (optional)
Use this keyword to specify the filename for the output statistics filename. Output
statistics files maybe viewed using the View Statistics File utility (see Statistics in
Chapter 5 of the ENVI Users Guide).

STDV (optional)
Use this optional keyword to specify a named variable that will contain the array of
data standard deviations, one for each band position.

TO_SCREEN (optional)
Set this keyword to print the report on the screen. This report presents all of the plot
and text information in a single dialog on the screen.

XFAC (optional)
Use this optional keyword to specify a X skip factor for computing statistics. XFAC
is a floating point number greater than or equal to one. The default is 1.0. For
example, to compute statistics using every tenth pixel set XFAC to 10.

ENVI Reference Guide

ENVI_STATS_DOIT

482

Chapter 2: ENVI Routines

YFAC (optional)
Use this optional keyword to specify a Y skip factor for computing statistics. YFAC
is a floating point number greater than or equal to one. The default is 1.0. For
example, to compute statistics using every tenth line set YFAC to 10.

Example
pro example_envi_stats_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Get the samples, lines and # bands
; for the input file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
;
; Set the dims and pos to calculate
; statistics for all data (spatially and
; spectrally) in the file.
;
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
;
; Calculate the basic statistics and the
; histogram for the input data file. Print
; out the calculated information.
;
envi_doit, envi_stats_doit, fid=fid, pos=pos, $
dims=dims, comp_flag=3, dmin=dmin, dmax=dmax, $
mean=mean, stdv=stdv, hist=hist
;
print, Minimum , dmin

ENVI_STATS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

483

print, Maximum , dmax


print, Mean , mean
print, Standard Deviation , stdv
;
for i=0,nb-1 do begin
print, Histogram Band , i+1
print, hist[*,i]
endfor
;
; Exit ENVI
;
envi_batch_exit
end

See Also
CLASS_STATS_DOIT
ENVI_GET_STATISTICS
ENVI_WRITE_STATISTICS

ENVI Reference Guide

ENVI_STATS_DOIT

484

Chapter 2: ENVI Routines

ENVI_SUM_DATA_DOIT
Use this program to calculate a number of statistical parameters on a set of bands.
This routine can be used to sum all the bands into an new output band and/or create a
number of other statistics as specified by COMPUTE_FLAG. All operates are done
pixel by pixel over the selected number of bands.

Syntax
ENVI_DOIT, ENVI_SUM_DATA_DOIT

Keywords
COMPUTE_FLAG
Use this keyword to specify which of the output bands to calculate.
COMPUTE_FLAG is a seven element array of ones and zeros where a one indicates
the that the corresponding output band should be calculated. COMPUTE_FLAG has
the following definitions:

COMPUTE_FLAG[0] Compute the sum of the bands defined by POS

COMPUTE_FLAG[1] Compute the sum squared of the bands defined by


POS

COMPUTE_FLAG[2] Compute the mean of the bands defined by POS

COMPUTE_FLAG[3] Compute the standard deviation of the bands


defined by POS

COMPUTE_FLAG[4] Compute the variance of the bands defined by POS

COMPUTE_FLAG[5] Compute the skewness of the bands defined by POS

COMPUTE_FLAG[6] Compute the kurtosis of the bands defined by POS

COMPUTE_FLAG[7] Compute the mean absolute deviation of the bands


defined by POS

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

ENVI_SUM_DATA_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

485

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY (optional)
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OUT_DT
Use this keyword to specify the output data type as either floating point or double
precision. OUT_DT is a long integer using the IDL data type conventions
(4=floating-point (32-bits), 5 = double-precision floating point (64-bits)).

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

ENVI Reference Guide

ENVI_SUM_DATA_DOIT

486

Chapter 2: ENVI Routines

Example
pro example_envi_sum_data_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keyword to process all the
; spatial and all the spectral data.
; Set the keyword COMPUTE_FLAG to
; compute the sum of the bands, the
; sum squared of the bands, the mean
; of the bands, and the standard
; deviation of the bands.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
compute_flag = [1,1,1,1,0,0,0,0]
out_dt = 4
;
; Call the processing routine to
; sum the data together.
;
envi_doit, envi_sum_data_doit, $
fid=fid, pos=pos, dims=dims, $
out_name=out_name, out_dt=out_dt, $
compute_flag=compute_flag
;
; Exit ENVI
;
envi_batch_exit
end

ENVI_SUM_DATA_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

487

See Also
ENVI_STATS_DOIT

ENVI Reference Guide

ENVI_SUM_DATA_DOIT

488

Chapter 2: ENVI Routines

ENVI_SYNTHETIC_COLOR_DOIT
Use this program to calculate a synthetic color image from a single grayscale band.
This program uses a low pass filter, high pass filter and saturation value as inputs into
a Hue-Saturation-Value (HSV) transform to create a synthetic color image.

Syntax
ENVI_DOIT, ENVI_SYNTHETIC_COLOR_DOIT

Arguments
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

H_KSIZE
Use this keyword to specify the high pass kernel size for the filter. The high pass filter
is the value for the HSV transform. H_KSIZE is a long integer greater than one.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

ENVI_SYNTHETIC_COLOR_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

489

L_KSIZE
Use this keyword to specify the low pass kernel size for the filter. The low pass filter
is the hue for the HSV transform. L_KSIZE is a long integer greater than one.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify a one elements array of the band position to perform the
operations on. POS is a single element long array ranging from 0 to the number of
bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

SAT_VALUE
Use this keyword to specify a saturation value for the HSV transform. SAT_VALUE
is a floating point number from zero to one.

Example
pro example_envi_synthetic_color_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid

ENVI Reference Guide

ENVI_SYNTHETIC_COLOR_DOIT

490

Chapter 2: ENVI Routines


if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords DIMS to
; processes all spatial. Set the
; keyword POS to calculate the
; synthetic color for the first
; band. Set the output band
; names to RGB.
;
envi_file_query, fid, ns=ns, nl=nl
dims = [-1, 0, ns-1, 0, nl-1]
pos = [0]
out_bname = [R,G,B]
out_name = testimg
;
; Call the synthetic color processing
; routine. Set the low and high pass
; kernels to 10 pixels and use a
; saturation value of .5 for the HSV
; transform.
;
envi_doit, envi_synthetic_color_doit, $
fid=fid, pos=pos, dims=dims, $
out_name=out_name, out_bname=out_bname, $
h_ksize=10, l_ksize=10, sat_value=.5, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

See Also
MUNSELL_DOIT
MUNSELL_INV_DOIT
RGB_ITRANS_DOIT
RGB_TRANS_DOIT

ENVI_SYNTHETIC_COLOR_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

491

ENVI_THERMAL_CORRECT_DOIT
The ENVI_THERMAL_CORRECT_DOIT procedure computes the thermal infrared
atmospheric correction. The input into this routine must be a thermal multi-band
image with associated wavelength values. If wavelength units are not specified in the
file header they must be supplied with the optional WL_UNITS keyword. The image
should be in units of (W/m2/m/sr) and the optional keyword DATA_SCALE is used
to convert the image to these units. The keywords METHOD_LF and METHOD_PS
allow control of the data gain and offset calculations. Additional keywords allow the
output of the gain and offset file and the plotting of the transmission/upwelling.

Syntax
ENVI_DOIT, ENVI_THERMAL_CORRECT_DOIT [, /DATA_SCALE],
DIMS=array, FID=fileID , /IN_MEMORY | OUT_NAME=string
[, /MAKEPLOTS], METHOD_LF={0 | 1}, METHOD_PS={0 | 1}
[, NESR=value] [, OUT_BNAME=string array] [, OUT_CFF=string],
POS=array [, R_FID=fileID] [, WL_UNITS=integer]

Arguments
None

Keywords
DATA_SCALE (optional)
Use this optional keyword to specify the data scaling needed to convert the image to
(W/m2/m/sr) prior to calculating the thermal atmospheric correction. The default is
to perform no data scaling.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

ENVI Reference Guide

ENVI_THERMAL_CORRECT_DOIT

492

Chapter 2: ENVI Routines

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

MAKEPLOTS (optional)
Set this optional keyword to plot the transmission/upwelling of the data. The default
is to not plot the data.

METHOD_LF
Use this keyword to specify the method for fitting the line in the data gain and offset
calculation. METHOD_LF is an integer number with one of the following values:

0 = Top of Bin

1 = Normalized Regression (requires the NESR keyword)

METHOD_PS
Use this keyword to specify the regression method in the data gain and offset
calculation. METHOD_PS is an integer number with one of the following values:

0 = All Pixels

1 = Max Hit

NESR (optional)
Use this keyword to specify the value for NESR (a measure of the sensor noise).
NESR must be specified when METHOD_LF is equal to one.

OUT_BNAME (optional)
Use this keyword to specify a string array of output band names, if desired.

ENVI_THERMAL_CORRECT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

493

OUT_CFF (optional)
Use this optional keyword to specify an output filename for the gain and offset values
used to atmospherically correct each band. The file will contain a gain and offset
value for each band specified by the POS array. The default is to not save the gain and
offset value to a file.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

WL_UNITS (optional)
Use this keyword to specify the wavelength units for the file specified by FID.
WL_UNITS is required when the file header does not contain any wavelength units.

See Also
EMITTANCE_CALC_DOIT

ENVI Reference Guide

ENVI_THERMAL_CORRECT_DOIT

494

Chapter 2: ENVI Routines

ENVI_TILE_DONE
This procedure frees the tile request once tile processing is complete.

Syntax
ENVI_TILE_DONE, Tile_id

Arguments
Tile_id
The tile ID as returned from ENVI_INIT_TILE.

Example
envi_tile_done, tile_id

Notes
This procedure must be called once the processing routine has completed the tiling
process.

See also
ENVI_INIT_TILE, ENVI_GET_TILE

ENVI_TILE_DONE

ENVI Reference Guide

Chapter 2: ENVI Routines

495

ENVI_TOGGLE_CATCH
Use this routine to toggle the ENVI error catching handling mechanism on and off.
When toggled off the catch mechanism will not redirect IDL programming or
execution errors. Instead they will be handled according to IDL. This routine is useful
when debugging user developed ENVI routines.

Syntax
ENVI_TOGGLE_CATCH

ENVI Reference Guide

ENVI_TOGGLE_CATCH

496

Chapter 2: ENVI Routines

ENVI_TRANSLATE_PROJECTION_NAME
ENVI supports a number of different projection types. This function translates
between the projection name string and the projection type integer value and viceversa. When a projection name string is input, this function returns the integer
projection type value. When an integer projection type value is input, this function
returns the projection name string.

Syntax
Result = ENVI_TRANSLATE_PROJECTION_NAME(Val)

Arguments
Val
Val can be either an integer or a string. If Val is an integer, the function returns the
string-format description of the projection name. If Val is a string, the function
returns the integer code describing the projection type.

Example
type = envi_translate_projection_name(State Plane)

or
proj_name = envi_translate_projection_name(3)

See Also
ENVI_MAP_INFO_CREATE

ENVI_TRANSLATE_PROJECTION_NAME

ENVI Reference Guide

Chapter 2: ENVI Routines

497

ENVI_TRANSLATE_PROJECTION_UNITS
ENVI supports a number of different projection units. This function translates
between the projection units string and the projection units integer value and viceversa. When a projection units string is input, this function returns the integer
projection units value. When an integer projection units value is input, this function
returns the projection units string.

Syntax
Result = ENVI_TRANSLATE_PROJECTION_UNITS(Val)

Arguments
Val
Val can be either an integer or a string. If Val is an integer, the function returns the
string-format description of the projection units. If Val is a string, the function returns
the integer code describing the projection units.
Note
Because additional unit types are likely to be added in future releases of ENVI, it is
strongly recommended that you use string descriptors rather than integer descriptors
when referring projection units. See the example below for details on how to do
this.

Example
units = envi_translate_projection_units(Meters)

See Also
ENVI_MAP_INFO_CREATE

ENVI Reference Guide

ENVI_TRANSLATE_PROJECTION_UNITS

498

Chapter 2: ENVI Routines

ENVI_USER_DEFINED_ANNOTATION
Use this routine to create an ENVI annotation file or append items to an existing
annotation file. If the annotation file does not exist ENVI will create a new annotation
file and add the specified item. If the annotation file exists each subsequent call to
ENVI_USER_DEFINED_ANNOTATION will add another annotation item to the
file. The desired item is specified by the appropriate keyword and any associated
parameter, keywords and optional keywords.

Syntax
ENVI_USER_DEFINED_ANNOTATION, Name, X, Y

Arguments
Name
A string variable specifying the annotation filename. If Name does not exist ENVI
will create a new annotation file. If Name exists ENVI will append the desired item to
the annotation file.

X
The X pixel location for the annotation item.

Y
The Y pixel location for the annotation item.

Keywords
ALIGN (optional)
Use this optional keyword to specify the text alignment for annotation objects
supporting this keyword. ALIGN is a floating point number with one of the following
values:

= Left justified

0.5 = Centered

= Right justified

ENVI_USER_DEFINED_ANNOTATION

ENVI Reference Guide

Chapter 2: ENVI Routines

499

ARROW (optional)
Set this keyword to specify that the annotation item is an arrow. If ARROW is set the
X and Y location parameters are not used but you must specify the keywords XPTS
and YPTS to define the two end points of the arrow (in image coordinates). Optional
keywords that can be used with ARROW include COLOR, FILL_MODE,
FILL_ORIEN, FILL_SPACING, HEAD_ANGLE, HEAD_PCT, LSTYLE, and
THICK.

BGCOLOR (optional)
Use this optional keyword to specify the background color index for annotation
objects supporting this keyword. BGCOLOR is an integer color index where:
0=black, 1=white, 2=red, etc. Set BGCOLOR equal to -1 for no background.

CHARSIZE (optional)
Use this optional keyword to specify the character size for annotation objects
supporting this keyword. CHARSIZE is a floating point value specifying the
character size.

COLOR (optional)
Use this optional keyword to specify the color index for annotation objects
supporting this keyword. COLOR is an integer color index into the graphic colors
where the default colors are, 0=black, 1=white, 2=red, etc.

COL_RAMP (optional)
Set this keyword to specify that the annotation item is a color ramp. If COL_RAMP
is set the X and Y location parameters must be set in image coordinates. Optional
keywords that can be used with COL_RAMP include: BGCOLOR, COLOR,
CHARSIZE, FONT, RAMP_LENGTH, RAMP_INC, RAMP_MAX_VAL,
RAMP_MIN_VAL, RAMP_ORIEN, RAMP_PRECISION, RAMP_WIDTH, and
THICK.

FILL_MODE (optional)
Use this optional keyword to specify the IDL fill style for annotation objects
supporting this keyword. FILL_MODE is an integer specifying the IDL fill style,
which is one of the following possible values:

0 = no fill

1 = solid fill

ENVI Reference Guide

ENVI_USER_DEFINED_ANNOTATION

500

Chapter 2: ENVI Routines

2 = solid line fill

3 = dotted line fill

4 = dashed line fill

5 = dash dot line fill

6 = dash dot dot line fill

7 = long dash line fill

FILL_ORIEN (optional)
Use this optional keyword to specify the rotation of fill for annotation objects
supporting this keyword. FILL_ORIEN is an integer greater than 1 specifying the fill
rotation.

FILL_SPACING (optional)
Use this optional keyword to specify the spacing of fill for annotation objects
supporting this keyword. FILL_SPACING is floating point number indicating the fill
spacing. This keyword is only used for FILL_MODE greater than one.

FONT (optional)
Use this optional keyword to specify the font for annotation objects supporting this
keyword. FONT is a string value specifying either a hershey font (e.g., !3 -!20)
or a valid name for a true type font (e.g., Courier).

IMAGE (optional)
Use this keyword to specify and annotation image. IMAGE is a byte array of
(NS,NL) for grayscale or (NS,NL,3) for RGB images. If IMAGE is set the X and Y
location parameters must be set in image coordinates and they reference the lower
left corner of IMAGE.

LSTYLE (optional)
Use this optional keyword to specify the IDL line style for annotation objects
supporting this keyword. LSTYLE is an integer specifying the IDL line style.

MAP_KEY (optional)
Set this keyword to specify that the annotation item is a map key. If MAP_KEY is set
the X and Y location parameters must be set (in image coordinates) and the keyword
KEY_COLORS and KEY_NAMES must be specified. Optional keywords for

ENVI_USER_DEFINED_ANNOTATION

ENVI Reference Guide

Chapter 2: ENVI Routines

501

MAP_KEY are BGCOLOR, CHARSIZE, COLOR, FONT, KEY_FILL_MODE,


KEY_FILL_ORIEN, KEY_FILL_SPACING, and THICK.

ORIEN (optional)
Use this optional keyword to specify the orientation for annotation objects supporting
this keyword. ORIEN is an integer value specifying the clockwise rotation angle.

POLYGON (optional)
Set this keyword to specify that the annotation item is a polygon. If POLYGON is set
the X and Y location parameters are not used but you must specify the keywords
XPTS and YPTS to define the vertices of the polygon (in image coordinates).
Optional keywords that can be used with POLYGON include COLOR,
FILL_MODE, FILL_ORIEN, FILL_SPACING, LSTYLE, and THICK.

POLYLINE (optional)
Set this keyword to specify that the annotation item is a polyline. If POLYLINE is set
the X and Y location parameters are not used but you must specify the keywords
XPTS and YPTS to define the polyline vertices (in image coordinates). Optional
keywords that can be used with POLYLINE include COLOR, LSTYLE, and THICK.

SCALE_BARS (optional)
Set this keyword to specify that the annotation item is a scale bar. If SCALE_BARS
is set your must specify the X and Y location parameters (in image coordinates) and
the PIXEL_SIZE keyword. Optional keywords that can be used with SCALE_BARS
include BGCOLOR, COLOR, FONT, SCALE_FLAG, SCALE_HEIGHT,
SCALE_INC, SCALE_LENGTH, SCALE_SUB_INC, SCALE_TITLES, and
THICK.

STR_TEXT (optional)
Use this keyword to specify the text string for the annotation item TEXT. Multiple
lines of text must be delineated with !C!C, for example Hello!C!CWorld will
print Hello and World on separate lines.

TEXT (optional)
Set this keyword to specify that the annotation item is a text string. If TEXT is set you
must specify the X and Y location parameters and the STR_TEXT keyword. Optional
keywords that can be used with TEXT include ALIGN, BGCOLOR, CHARSIZE,
COLOR, FONT, ORIEN, and THICK.

ENVI Reference Guide

ENVI_USER_DEFINED_ANNOTATION

502

Chapter 2: ENVI Routines

THICK (optional)
Use this optional keyword to specify the line thickness for annotation objects
supporting this keyword. THICK is an integer value specifying the line thickness of
hershey font characters.

USE_MAP_COORDS (optional)
Set this keyword to the FID of a georeferenced image to allow the (x, y) and (xpts,
ypts) coordinates sent to this procedure to be in map coordinates instead of file
coordinates.

Keywords for ARROW


HEAD_ANGLE (optional)
Use this keyword to specify the angle for the head of an ARROW annotation object.
HEAD_ANGLE is a floating point value between greater than zero specifying the
angel in degrees of the arrows head. The default is 35.

HEAD_PCT (optional)
Use this keyword to specify the size of the head for an ARROW annotation object.
HEAD_PCT is a floating point value between zero and one specifying the percentage
of the head size versus the overall length. The default is .15.

Keywords for COLOR_RAMP


RAMP_INC (optional)
Use this keyword to specify the number of color ramp increments. RAMP_INC is an
integer value specifying number of increments. The default is 3.

RAMP_LENGTH (optional)
Use this keyword to specify the color ramp length in pixels. RAMP_LENGTH is an
integer value specifying the color ramp length in pixels. The default is 200.

RAMP_MAX_VAL (optional)
Use this keyword to specify the value associated with the high end of the color ramp.
RAMP_MAX_VAL is a floating point value.

ENVI_USER_DEFINED_ANNOTATION

ENVI Reference Guide

Chapter 2: ENVI Routines

503

RAMP_MIN_VAL (optional)
Use this keyword to specify the value associated with the low end of the color ramp.
RAMP_MIN_VAL is a floating point value.

RAMP_ORIEN (optional)
Use this keyword to specify the color ramp orientation. RAMP_ORIEN is one of the
following integer values:

0 = Horizontal low to high

1 = Vertical high to low

2 = Horizontal high to low

3 = Vertical low to high

RAMP_PRECISION (optional)
Use this keyword to specify the number of precision digits for color ramp values.
RAMP_PRECISION is an integer value. The default is 1.

RAMP_WIDTH (optional)
Use this keyword to specify the color ramp width in pixels. RAMP_WIDTH is an
integer value specifying the color ramp width in pixels. The default is 25.

Keywords for MAP_KEY


KEY_FILL_MODE (optional)
Use this keyword to specify the IDL fill mode for map key polygons.
KEY_FILL_MODE is an integer value indicating the IDL fill mode. The default is
zero, no fill.

KEY_FILL_ORIEN (optional)
Use this keyword to specify the orientation for fill. KEY_FILL_ORIEN is an integer
value greater than one indicating the rotation for the fill. The default is zero, no
rotation.

ENVI Reference Guide

ENVI_USER_DEFINED_ANNOTATION

504

Chapter 2: ENVI Routines

KEY_FILL_SPACING (optional)
Use this keyword to specify the spacing for fill. KEY_FILL_SPACING is floating
point value indicating the fill spacing. KEY_FILL_SPACING is only valid when
KEY_FILL_MODE is greater than one. The default is .1.

Keywords for SCALE_BARS


SCALE_FLAG (optional)
Use this keyword to specify which units are active for a scale bar. SCALE_FLAG is a
four element bytarr of zeros and ones where a one make the corresponding units
active. The elements of SCALE_FLAG correspond to the units as follows [km, miles,
meters, feet]. The default is [1,0,0,0] displaying only kilometer units.

SCALE_HEIGHT (optional)
Use this keyword to specify the height in pixels for the scale bars. SCALE_HEIGHT
is a integer value specifying the scale bar height in pixels. The default is 25.

SCALE_INC (optional)
Use this keyword to specify the number of increments for each type of scale bar.
SCALE_INC is a four element integer array specifying the number of increments for
each of the units, [km, miles, meters, feet]. The default is [1,1,1,1].

SCALE_LENGTH (optional)
Use this keyword to specify the length in map scale for each type of scale bar.
SCALE_LENGTH is a four element floating point array specifying the length in map
scale for each of the units, [km, miles, meters, feet].

SCALE_SUB_INC (optional)
Use this keyword to specify the number of sub-increments for the first unit of a given
scale bar. SCALE_SUB_INC is a four element integer array specifying the number of
increments for each of the units, [km, miles, meters, feet]. The default is [4,4,4,4].

SCALE_TITLE (optional)
Use this keyword to specify the titles for each scale bar. SCALE_TITLE is a four
element string array specifying the titles for each of the units, [km, miles, meters,
feet]. The default is [Kilometers, Miles, Meters, Feet].

ENVI_USER_DEFINED_ANNOTATION

ENVI Reference Guide

Chapter 2: ENVI Routines

505

Example
pro annotation_demo
compile_opt strictarr
; For this example, just pick the bhtmref.img that comes with ENVI
in_file = DIALOG_PICKFILE()
; Now were opening the file
ENVI_OPEN_FILE, in_file, R_FID = in_fid
; This next command will add a text object to the annotation file
; example_annotation_file.ann
; The lower left corner of the text object will be at the
; ENVI image coordinates of 50,50. The text object has 2 lines,
; which both say, "Text Test Object", and will be in red
; lettering.
ENVI_USER_DEFINED_ANNOTATION, 'example_annotation_file.ann', $
125, 50, STR_TEXT = 'Text!C!CTest Object', COLOR = 2, /TEXT,$
ALIGN = 0.5
; Now well add a small image, just a test picture.
; The lower left corner of the test picture will be at ENVI $
; image coordinate 50,140 which will place it just below our text.
image = BYTSCL(DIST(40))
ENVI_USER_DEFINED_ANNOTATION, 'example_annotation_file.ann', $
50, 140, image=image
;
;

If you restore the annotation file on the image in ENVI you


should see the objects placed as described above.

end

ENVI Reference Guide

ENVI_USER_DEFINED_ANNOTATION

506

Chapter 2: ENVI Routines

ENVI_VEG_INDEX_AVAILABLE_INDICES
This function determines the number of vegetation indices that can be calculated on
an input data file. It can optionally return the names of these indices, a classification
describing the purpose of the index, or, if no indices are available, a descriptive error
specifying the reason no indices are available.

Syntax
Result = ENVI_VEG_INDEX_AVAILABLE_INDICES (FID=FileID
[, ERROR_STRING=string] [, VI_LIST=array] [, VI_NAMES=string]
[, VI_TYPE=array])

Return Value
This routine returns the number of vegetation indices that can be calculated from the
input file; 0 (zero) if no indices can be calculated.

Arguments
FID
Use this keyword to specify the file ID for the input file.

Keywords
ERROR_STRING (optional)
Set this optional keyword to a named variable in which to return a descriptive error
string describing the reason that no vegetation indices are available, if the return
value of the function is 0. Otherwise, this keyword is undefined.

VI_LIST (optional)
Set this keyword to a named variable in which to return a long integer array
containing the numeric indices associated with each vegetation index available for
calculation, if any. These indices can be used to specify the desired subset of indices
for the ENVI_VEG_INDEX_DOIT routine to calculate. If the
ENVI_VEG_INDEX_AVAILABLE_INDICES return value is 0, this keyword is
undefined.

ENVI_VEG_INDEX_AVAILABLE_INDICES

ENVI Reference Guide

Chapter 2: ENVI Routines

507

VI_NAMES (optional)
Set this optional keyword to a named variable in which to return a string array
containing the names of all vegetation indices available for calculation, if any. See
Vegetation Indices in Appendix E of the ENVI Users Guide for a complete list of
VI names. If the ENVI_VEG_INDEX_AVAILABLE_INDICES return value is 0,
this keyword is undefined.

VI_TYPE (optional)
Set this optional keyword to a named variable in which to return a string containing
the names of the categories for all vegetation indices available for calculation. See
Vegetation Indices in Appendix E of the ENVI Users Guide for a complete list of
VI categories. If the ENVI_VEG_INDEX_AVAILABLE_INDICES return value is 0,
this keyword is undefined.

Example
The following example code shows how to calculate a subset of VIs.
pro example_veg_index_2
compile_opt strictarr
; This example calculates a subset of the available vegetation
; indices determined using both
; the ENVI_VEG_INDEX_AVAILABLE_INDICES routine
; and the ENVI_VEG_INDEX_DOIT routine
; First, restore all the base save files.
envi, /restore_base_save_files
; Initialize ENVI and send all errors
; and warnings to the file batch.txt.
envi_batch_init, log_file=batch.txt
; Open the input file
envi_open_file, envi_pickfile(), r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
; Find the list of available vegetation indices for this file.
if (~ENVI_VEG_INDEX_AVAILABLE_INDICES(fid, vi_list=vi_list, $
vi_names=vi_names, vi_type=vi_type, $
error_string=error_string)) then begin
print, error_string
envi_batch_exit
return

ENVI Reference Guide

ENVI_VEG_INDEX_AVAILABLE_INDICES

508

Chapter 2: ENVI Routines


endif
; Find the subset of indices for greenness to calculate.
vi_subset = where(vi_type eq Broadband Greenness, count)
if (count eq 0) then begin
print, Error: No broadband greenness indices are available.
envi_batch_exit
return
endif
; Calculate the greenness indices.
envi_doit, envi_veg_index_doit, fid=fid, in_memory=0, $
out_name=veg_indices.dat, vi_list=vi_list[vi_subset]
envi_batch_exit
end

See Also
ENVI_VEG_INDEX_DOIT

ENVI_VEG_INDEX_AVAILABLE_INDICES

ENVI Reference Guide

Chapter 2: ENVI Routines

509

ENVI_VEG_INDEX_DOIT
The ENVI_VEG_INDEX_DOIT procedure calculates vegetation indices from a
spectral input image. The input spectral data must be atmospherically corrected and
calibrated to reflectance.

Syntax
ENVI_DOIT, ENVI_VEG_INDEX_DOIT [, /CROSS_CHECK] [, DIMS=array]
, FID=fileID [, M_FID=fileID] [, M_POS=value]
[, OUT_NAME=string | /IN_MEMORY] [, R_FID=fileID] [, VI_LIST=string]

Arguments
None.

Keywords
CROSS_CHECK (optional)
Set this optional keyword to perform biophysical cross checking on the output.
Biophysical cross checking does pixel by pixel comparisons between the vegetation
indices to determine areas where one index value indicates that another index value
has a low probability of validity. The values for any pixel with a low probability of
validity are set to the data ignore value. The default is to not perform biophysical
cross checking.

DIMS (optional)
Use this optional keyword to specify the spatial dimensions on which to perform the
operation. The DIMS keyword is a five-element array of long integers with the
following definitions:
Array Element

ENVI Reference Guide

Description

DIMS[0]

Unused for this function. Set to 1.

DIMS[1]

The starting X pixel. The first pixel is


number zero.

ENVI_VEG_INDEX_DOIT

510

Chapter 2: ENVI Routines

Array Element

Description

DIMS[2]

The ending X pixel.

DIMS[3]

The starting Y pixel. The first pixel is


number zero.

DIMS[4]

The ending Y pixel.

FID
Use this keyword to specify the file ID for the input file.

M_FID (optional)
Use this optional keyword to specify the file ID for the mask file. It is the value
returned from the keyword R_FID in the ENVI_OPEN_FILE procedure. M_FID is a
long integer with a value greater than zero.

M_POS (optional)
Use this optional keyword to specify the band position of the mask band. M_POS is a
long value greater than or equal to zero. This keyword is ignored unless the M_FID
keyword is specified.

OUT_NAME (optional)
Use this optional keyword to specify an output file name for the resulting data. If the
IN_MEMORY keyword is set, this keyword is not needed.

IN_MEMORY (optional)
Use this optional keyword to store output in memory. If IN_MEMORY is not set,
output is stored on disk and the OUT_NAME keyword is required.

R_FID (optional)
Use this optional keyword to specify a named variable that contains the file ID for the
processed data. This file ID is used to access the processed data.

ENVI_VEG_INDEX_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

511

VI_LIST (optional)
Use this optional keyword to which vegetation indices to calculate. Each vegetation
index is specified as a numeric index into the array of all available vegetation indices.
This list is derived from the VI_LIST values returned from the
ENVI_VEG_INDEX_AVAILABLE_INDICES function. The default is to calculate
all available vegetation indices. If any indices are requested that cannot be calculated
on the input dataset, only the available requested indices will be calculated, unless the
session is an interactive ENVI session. If this session is an interactive ENVI session,
the user is prompted if the valid selected indices should be calculated.

Example
The following is example code to calculate all available VIs.
pro example_veg_index_1
compile_opt strictarr
; This example calculates all available vegetation indices on an
; input file.
; First, restore all the base save files.
envi, /restore_base_save_files
; Initialize ENVI and send all errors
; and warnings to the file batch.txt.
envi_batch_init, log_file=batch.txt
; Open the input file.
envi_open_file, envi_pickfile(), r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
; Calculate the vegetation indices with
; biophysical cross checking enabled to help validate the results
envi_doit, envi_veg_index_doit, fid=fid, in_memory=0, $
out_name=veg_indices.dat, /cross_check
envi_batch_exit
end

See Also
ENVI_VEG_INDEX_AVAILABLE_INDICES

ENVI Reference Guide

ENVI_VEG_INDEX_DOIT

512

Chapter 2: ENVI Routines

ENVI_WRITE_DBF_FILE
Use this routine to write a DBF attribute file for an ENVI Vector File (EVF).
Attributes are used to describe each record in an EVF file. There must be a one-toone correspondence between number of EVF records (i.e., points, polylines, and
polygons) and the number of DBF records. The fields in an attribute record are a mix
of numbers (byte, integer, long and floating point) and strings. All attribute records in
a single DBF file must have the same field structure (i.e., an array of identical
structures).

Syntax
ENVI_WRITE_DBF_FILE, Filename, Attributes

Arguments
Filename
A string value that specifies the output DBF file name. For ENVI to recognize the
attribute table when reading the EVF file, the filename should consist of the root
name that matches the corresponding EVF file with a .DBF extension.

Attributes
The attributes are defined using an IDL anonymous structure variable. Each attribute
is a field within the structure. The structure tag names are used as the attribute field
names (the maximum field name length is 11 characters). There can be any number of
attribute fields comprised of numbers (byte, integer, long and floating point) and
strings. The structure should be replicated into an array with the same number of
elements as there are records in the corresponding EVF file.

Example
pro create_new_evf_file
;
; Create a Geographic projection
; with the default datum and units.
;
proj = envi_proj_create(/geographic)
;
; Define a polyline vector in Lat/Lon coordinates
;
polyline = [ $

ENVI_WRITE_DBF_FILE

ENVI Reference Guide

Chapter 2: ENVI Routines

513

-106.904,
41.5887, $
-106.821,
42.2302, $
-106.013,
42.2183, $
-105.206,
41.3749, $
-105.657,
40.5078, $
-105.835,
39.5574, $
-105.170,
38.8447, $
-104.125,
39.4862, $
-103.269,
40.0563, $
-103.269,
40.0682, $
-102.913,
39.0585, $
-102.901,
39.0585, $
-102.901,
39.0348, $
-103.210,
38.4289, $
-103.804,
38.3695 ]
polyline = reform(polyline, 2, 15)
;
; define a polygon in Lat/Lon coordinates
; (note first and last coords are identical)
;
polygon = [ $
-104.113,
41.6956, $
-103.994,
42.1589, $
-103.934,
41.6838, $
-103.471,
41.8738, $
-103.887,
41.5531, $
-103.863,
41.0185, $
-103.851,
41.0185, $
-104.041,
41.4818, $
-104.041,
41.4937, $
-104.552,
41.2680, $
-104.220,
41.6006, $
-104.422,
42.0995, $
-104.113,
41.6956 ]
polygon = reform(polygon, 2, 13)
;
; define a set of discrete points in Lat/Lon coordinates
;
points = [ $
-106.572,
39.6643, $
-106.643,
39.5218, $
-106.453,
39.4386, $
-106.417,
39.6168, $
-106.595,
39.4386, $
-106.774,
39.2011, $
-106.215,
39.4030, $
-106.393,
39.2961, $
-106.560,
39.1892, $
-106.536,
38.9872, $

ENVI Reference Guide

ENVI_WRITE_DBF_FILE

514

Chapter 2: ENVI Routines


-106.227,
39.1417, $
-106.192,
39.1179, $
-106.263,
38.9635, $
-106.073,
39.1298, $
-106.073,
39.2367 ]
points = reform(points, 2, 15)
;
; Initialize the new EVF file
;
evf_ptr = envi_evf_define_init(sample.evf, $
projection=proj, data_type=4, $
layer_name=Sample EVF File)
if (ptr_valid(evf_ptr) eq 0) then return
;
; add the discrete points as individual records
;
for i=0,14 do $
envi_evf_define_add_record, evf_ptr, points[*,i]
;
; add the polyline record
;
envi_evf_define_add_record, evf_ptr, polyline
;
; add the polygon record
;
envi_evf_define_add_record, evf_ptr, polygon
;
; Finish defining the new EVF file and
; then close the EVF file
;
evf_id = envi_evf_define_close(evf_ptr, /return_id)
envi_evf_close, evf_id
;
; create an attribute file for this new EVF file
;
; records 1-15 are individual points
; record 16 is a polyline
; record 17 is a polygon
;
attributes = replicate( {name:, id:0L}, 17)
for i=0,14 do begin
attributes[i].name = Sample Point + strtrim(i+1,2)
attributes[i].id = i+1
endfor
attributes[15].name = Sample Polyline
attributes[15].id = 16
attributes[16].name = Sample Polygon
attributes[16].id = 17

ENVI_WRITE_DBF_FILE

ENVI Reference Guide

Chapter 2: ENVI Routines

515

envi_write_dbf_file, sample.dbf, attributes


end

See Also
ENVI_EVF_CLOSE
ENVI_EVF_DEFINE_ADD_RECORD
ENVI_EVF_DEFINE_CLOSE
ENVI_EVF_DEFINE_INIT

ENVI Reference Guide

ENVI_WRITE_DBF_FILE

516

Chapter 2: ENVI Routines

ENVI_WRITE_ENVI_FILE
Use this procedure to convert an IDL image array to an ENVI image. The input data
is an IDL image array in memory dimensioned as either BSQ [samples,lines,bands],
BIL [samples,bands,lines] or BIP [bands,samples,lines]. The resulting ENVI image
can either be stored as a disk file with an associated header file or stored in memory.
Optional keywords can be used to define specific information about the image data in
the ENVI header.

Syntax
ENVI_WRITE_ENVI_FILE, Data

Arguments
Data
A two or three-dimensional data array of type Byte, Integer, Unsigned Integer, Long
Integer, Unsigned Long Integer, Long 64 Integer, Unsigned Long 64 Integer, Floating
Point, Double Precision, Complex, or Double Complex. The data may be in BSQ
[samples,lines,bands], BIL [samples,bands,lines] or BIP [bands,samples,lines]
storage order. The DATA array will be converted to an ENVI image file.

Keywords
BBL (optional)
Use this optional keyword to specify an array of ones and zeros representing the good
and bad bands. The number of elements in BBL must be equal to the number of bands
in the image. A one represents a good band and a zero represents a bad band.

BNAMES (optional)
Use this optional keyword to specify the band names assigned to the data. BNAMES
is a string array of number-of-bands band names. The default band names are [band
1, band 2, etc.]

BYTE_ORDER (optional)
Use this optional keyword to specify a named variable that will contain a flag
indicating the byte order of the data. Set byte order to 1 for big-endian data (i.e., data

ENVI_WRITE_ENVI_FILE

ENVI Reference Guide

Chapter 2: ENVI Routines

517

generated on SUN, SGI, PowerMac. etc.) and to 0 for little-endian data i.e.,. data
generated on PC x86). The default is the byte order of the machine.

CLASS_NAMES (optional)
Use this optional keyword to specify a string array of class names for classification
images. The first element (class 0) is the Unclassified class. CLASS_NAMES
should only be specified if the result is a classification image. CLASS_NAMES is a
required keyword if the file type is equal to classification, otherwise, it is optional.

COMPRESSION (optional)
Set this optional keyword to write the file using the standard GZIP format. IDLs
GZIP support is based on the freely available ZLIB library version 1.1.3 by Mark
Adler and Jean-loup Gailly. This means that compressed files are 100% compatible
with the widely available gzip and gunzip programs.

DATA_TYPE
Use this keyword to specify the IDL data type of the file, using the following IDL
convention:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

DEF_BANDS (optional)
Set this optional keyword to a 1- or 3-element array containing which bands to
display upon opening the file in ENVI. If DEF_BANDS is set to a 1-element array,
then ENVI will load a grayscale display. If DEF_BANDS is set to a 3-element array,

ENVI Reference Guide

ENVI_WRITE_ENVI_FILE

518

Chapter 2: ENVI Routines

ENVI will load an RGB display. The values are 0-based, so to load bands 4, 3, and 2
of a 7-band image, set DEF_BANDS = [3,2,1].

DEF_STRETCH (optional)
Use this optional keyword to specify the default contrast stretch to be used whenever
the image is displayed. Set DEF_STRETCH equal to the value returned from
ENVI_DEFAULT_STRETCH_CREATE.

DESCRIP (optional)
Use this optional keyword to specify a text description of the data or of the type of
processing performed.

FILE_TYPE (optional)
Use this optional keyword to specify a named variable that will contain the integer
file type value. See ENVI_FILE_TYPE for details on how to determine the integer
file type value.

FUNC_COMPLEX (optional)
Set this optional keyword to indicate the Complex Lookup Function to determine
which image to display for complex data. This keyword should be set to one of the
following:

0 Power (ln(magnitude))

1 Magnitude (

2 Real (real portion of number)

3 Imaginary (imaginary portion)

imag inary
4 Phase ( arc tan -------------------------)

( real ) + ( imag inary )

real

Note
The default image is Power. Only set this keyword if the IDL data type of the image
is 6 = complex (2 x 32-bit) or 9 = double-precision complex (2 x 64-bit)

FWHM (optional)
Use this optional keyword to specify an array of full-width-half-maximum responses
for each band. The number of elements in this array is equal to the number of bands
in the image.

ENVI_WRITE_ENVI_FILE

ENVI Reference Guide

Chapter 2: ENVI Routines

519

GEO_POINTS (optional)
Use this optional keyword to specify a 16-element precision floating point double
array of geographic coordinates for the four corners. The array is comprised of four
groups of X and Y pixel locations and the corresponding latitude and longitude
values (negative for South latitude and negative for West longitude). The four groups
of points represent the four corners: upper left, upper right, lower left, lower right.
The array is defined as follows

GEO_POINTS[0:3] -> [X, Y, LAT, LON] - upper left

GEO_POINTS[4:7] -> [X, Y, LAT, LON] - upper right

GEO_POINTS[8:11] -> [X, Y, LAT, LON] - lower left

GEO_POINTS[12:15] -> [X, Y, LAT, LON] - lower right

IN_MEMORY (optional)
Set this optional keyword to specify that output should be stored in memory. If
IN_MEMORY is not set, output will be stored on disk, and OUT_NAME must be
specified.

INFO (optional)
Use this optional keyword to specify user defined information. INFO is used to store
information which can be passed to users spatial and spectral readers. INFO is
retrieved from ENVI_FILE_QUERY using the keyword H_INFO which is a handle
to the data. Use HANDLE_VALUE and the handle H_INFO to retrieve INFO.

INHERIT (optional)
Use this optional keyword to specify the file inheritance. Set INHERIT equal to the
value returned from ENVI_SET_INHERITANCE.

INTERLEAVE (optional)
Use this optional keyword to specify the file's interleave type. Set to zero to create the
file in BSQ format, to one to create the file in BIL format, and to two to create the file
in BIP format. The default is zero, BSQ format.

LOOKUP (optional)
Use this optional keyword to specify a long array of class RGB values. The
LOOKUP array contains one RGB triple for each class specified with the
NUM_CLASSES keyword. The dimensions of the array are [3,NUM_CLASSES]

ENVI Reference Guide

ENVI_WRITE_ENVI_FILE

520

Chapter 2: ENVI Routines

and the RGB triplet is ordered [R,G,B]. LOOKUP must be set when entering a
classification image.

MAP_INFO (optional)
Use this optional keyword to specify map information. Set MAP_INFO equal to the
structure returned from ENVI_MAP_INFO_CREATE.

NB
Use this keyword to specify the number of bands in the file.

NL
Use this keyword to specify a the number of lines in the file.

NS
Use this keyword to specify the number of samples in the file.

NUM_CLASSES (optional)
Use this optional keyword to specify the number of classes for classification files.
Remember to include the Unclassified class (class 0) in the number of classes. This
keyword should only be specified for classification files.

NO_COPY (optional)
Set this optional keyword to prohibit duplicating the Data array on output. If the
keyword is set, the Data argument array is incorporated into the ENVI session
directly, rendering the variable Data undefined after the call to ENVI_WRITE_FILE.
The default is to make a copy of the data.

NO_OPEN (optional)
Set this optional keyword to prohibit the addition of the file to the Available Bands
List. The default is to add the output file to the Available Bands List.

NO_WRITE (optional)
Set this optional keyword to prohibit writing an output header file to disk. The default
is to write an output header. It is possible (and valid) to add a file to the Available
Bands List and not write the header file to disk. If you set the NO_WRITE keyword
you will have to manually specify the file parameters when you open the file in a later
ENVI session. The keyword has no effect when the IN_MEMORY keyword is set.

ENVI_WRITE_ENVI_FILE

ENVI Reference Guide

Chapter 2: ENVI Routines

521

OFFSET
Use this keyword to specify the offset (in bytes) to the start of the data in the file.

OUT_DT (optional)
Use this optional keyword to specify the IDL data type of the file, using the following
IDL convention:
Note
Default output data type is the same as the input data type.

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer

OUT_NAME
Use this keyword to specify the file name (and path) of the disk file. OUT_NAME is
a string variable that ENVI will use to create and output the image data.
OUT_NAME is not required if the IN_MEMORY keyword is set.

PIXEL_SIZE (optional)
Use this optional keyword to specify the pixel size of images that are not
georeferenced. PIXEL_SIZE is a two-element floating point array specifying the X
and Y pixel size respectively.

ENVI Reference Guide

ENVI_WRITE_ENVI_FILE

522

Chapter 2: ENVI Routines

R_FID (optional)
Use this optional keyword to specify a named variable that will hold the file ID for
files that are added to the Available Bands List. The file ID is only set when the
OPEN keyword is also set.

READ_PROCEDURE (optional)
Use this optional keyword to specify a named variable that will contain a string array
of the procedure names for the spatial and spectral readers, respectively.

SENSOR_TYPE (optional)
Use this optional keyword to specify an integer value related to the sensor type. See
ENVI_SENSOR_TYPE for details on how to determine the integer sensor type
value.

SPEC_NAMES (optional)
Use this optional keyword to specify a named variable that will contain a string array
of spectral library names. The keyword SPEC_NAMES should only be set for a
spectral library file.

UNITS (optional)
Use this optional keyword to specify the PIXEL_SIZE units for images that are not
georeferenced. UNITS is an integer value returned from
ENVI_TRANSLATE_PROJECTION_UNITS. Georeferenced images do not use this
value. Instead they use the pixel size and units contained in the map information
structure.

WL (optional)
Use this optional keyword to specify an array of wavelength values. The number of
elements in this array is equal to the number of bands.

XSTART (optional)
Use this optional keyword to specify the X starting sample for the first pixel in the
file. The default is zero. XSTART is used in conjunction with YSTART to preserve
the location within the original file for subsetted files. When processing a file the
XSTART of the output file is typically set to the XSTART of the input file plus the
value of DIMS[1] (the starting sample).

ENVI_WRITE_ENVI_FILE

ENVI Reference Guide

Chapter 2: ENVI Routines

523

YSTART (optional)
Use this optional keyword to specify the Y starting line for the first pixel in the file.
The default is zero. YSTART in conjunction with XSTART are used to preserve the
spatial reference for subsetted files. When processing a file the YSTART of the
output file is typically set to the YSTART of the input file plus the value of DIMS[3]
(the starting line).

ZPLOT_AVERAGE (optional)
Use this optional keyword to specify a two-element long integer array for the X and
Y window size (in pixels) for the Z-Profile. The window size must be 1 or greater.
The Z-Profile is formed from the average of the profiles within the specified window.
The default window size is [1,1].

ZPLOT_TITLES (optional)
Use this optional keyword to specify a two element string array for X and Y axis
titles for any spectral plots derived from the image. The default X title is Band
Number for images with no wavelength information and Wavelength for images
with wavelength information. The default Y axis title is Value.

ZRANGE (optional)
Use this optional keyword to specify a two dimensional array for the lower and upper
spectral plot range.

Examples
The following example will generate a 256x256 three band BSQ byte ramp image
using the function BINDGEN. This image will be saved to disk using the filename
test.img and automatically added to the Available Bands List.

Create the image array


;
data = BINDGEN(256,256,3)
;
; Open the output file and write
; the image to disk
;
ENVI_WRITE_ENVI_FILE, data, out_name=test.img

The following example will create two classes (plus the Unclassified class) from a
single band ramp image, save the file to disk and add the file to the Available Bands
List. The Unclassified class will be Black [0,0,0], the first class will be Red [255,0,0]

ENVI Reference Guide

ENVI_WRITE_ENVI_FILE

524

Chapter 2: ENVI Routines

and the second class will be Yellow [255,255,0]. The class names will be
Unclassified, Red, and Yellow. The classification image will have the description
Example Classification Image and the band name Ramp Classification.
; Create a 2D ramp and then classify all values
; from 20 to 100 in the first class (classification
; data value equal to one) and classify all values
; from 101 to 220 into the second class
; (classification data value equal to two)
;
data = BINDGEN(256,256)
class = BYTE((data ge 20 and data le 100) + $
2B * (data ge 101 and data le 220))
;
; Create the classification information
;
class_names = [Unclassified,Red,Yellow]
lookup = [[0,0,0],[255,0,0],[255,255,0]]
bnames = [Ramp Classification]
descrip = Example Classification Image
file_type = ENVI_FILE_TYPE(ENVI Classification)
;
; Save the classification image to disk
;
ENVI_WRITE_ENVI_FILE, class, out_name=test.img,
num_classes=3, class_names=class_names, $
lookup=lookup, file_type=file_type, $
bnames=bnames, descrip=descrip

The next example will take a ramp image and assign a geographic projection to the
image with the upper left corner at 15 degrees south, 48 degrees west, and an X and Y
pixel size of one arc second. The map projection will be created using
ENVI_MAP_INFO_CREATE and the resulting structure will use the MAP_INFO
keyword when entering the data into ENVI.
;
; First create the ramp image. The ramp image
; would actually be replaced by a real
; georeferenced image.
;
data = BINDGEN(256,256)
;
; Create the items used for the projection
;
mc = [.5D,.5, -48,-15]
ps = [1D/3600, 1D/3600]
units = ENVI_TRANSLATE_PROJECTION_UNITS('Degrees')
map_info = ENVI_MAP_INFO_CREATE(/geographic, $
mc=mc, ps=ps, units=units)

ENVI_WRITE_ENVI_FILE

ENVI Reference Guide

Chapter 2: ENVI Routines

525

;
; Enter the data into ENVI
;;
ENVI_WRITE_ENVI_FILE, data, out_name=test.img, $
map_info=map_info

See Also
ENVI_ENTER_DATA
ENVI_SETUP_HEAD

ENVI Reference Guide

ENVI_WRITE_ENVI_FILE

526

Chapter 2: ENVI Routines

ENVI_WRITE_FILE_HEADER
Use this procedure to write/re-write an ENVI header file to preserve changes to user
defined header values. Once an ENVI file is open the user header values may be
changed programmatically using ENVI_ASSIGN_HEADER_VALUE. To preserve
these changes to files that reside on disk you must also write out the updated ENVI
header using ENVI_WRITE_FILE_HEADER.

Syntax
ENVI_WRITE_FILE_HEADER, Fid

Arguments
Fid
The file ID for the open file. This is the value returned from the keyword R_FID in
the ENVI_OPEN_FILE procedure. Fid is a long integer with a value greater than
zero. An invalid file ID is specified as -1.

Example
The following example will open the image file can_tmr.img using the
ENVI_OPEN_FILE routine. Once the file is open and a valid file ID is returned a
user defined header value for My Scale Factors is stored to the header using
ENVI_ASSIGN_HEADER_VALUE. The change is then queried using
ENVI_GET_HEADER_VALUE and the result printed to the ENVI log window. At
this point the header change exists only in the current ENVI session. In order to
preserve this change to the disk file the routine ENVI_WRITE_FILE_HEADER is
called to write an updated header to disk.
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then return
scale_factors = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
envi_assign_header_value, fid=fid, keyword=My Scale Factors, $
value=scale_factors, precision=3
values = envi_get_header_value(fid, My Scale Factors)

ENVI_WRITE_FILE_HEADER

ENVI Reference Guide

Chapter 2: ENVI Routines

527

print, My Scale Factors, values


envi_write_file_header, fid

See Also
ENVI_ASSIGN_HEADER_VALUE
ENVI_GET_HEADER_VALUE

ENVI Reference Guide

ENVI_WRITE_FILE_HEADER

528

Chapter 2: ENVI Routines

ENVI_WRITE_STATISTICS
This procedure is used to write statistics data to an ENVI statistics (.sta) file. The
values written to the statistics file are defined using the keyword arguments.

Syntax
ENVI_WRITE_STATISTICS, Filename

Arguments
Filename
The filename of the ENVI statistics (.sta) file to be written.

Keywords
COV (optional)
Use this keyword to specify the covariance for the image. COV is a (nb,nb) array
where nb is defined by CPOS. If COV is set then EVAL and EVEC must also be set.

CPOS (optional)
Use this keyword to specify the array of band indexes used to calculate COV, EVAL
and EVEC. The number of elements of CPOS define the nb for COV, EVAL, and
EVEC and may be different than the number of bands defined by FID. The default is
that COV, EVAL, and EVEC are calculated for all band in the file defined by FID.

DATA_TYPE (optional)
Use this keyword to specify the image data type. DATA_TYPE may be different that
the data type in the file defined by FID. DATA_TYPE is used during any subsequent
display of statistics by ENVI.

DMAX (optional)
Use this keyword to specify an array that contains the image maximums. DMAX is a
(nb) array where nb is equal to the number of bands in the file defined by FID.

ENVI_WRITE_STATISTICS

ENVI Reference Guide

Chapter 2: ENVI Routines

529

DMIN (optional)
Use this keyword to specify an array that contains the image minimums. DMIN is a
(nb) array where nb is equal to the number of bands in the file defined by FID.

EVAL (optional)
Use this keyword to specify the eigen values for the image. EVAL is a (nb,nb) array
where nb is defined by CPOS. If EVAL is set then COV and EVEC must also be set.

EVEC (optional)
Use this keyword to specify the eigen vectors for the image. EVEC is a (nb) array
where nb is defined by CPOS. If EVEC is set then COV and EVAL must also be set.

FID
Use this keyword to specify a file ID for defining the overall number of bands in the
statistics calculations. COV, EVAL, and EVEC use CPOS to save statistics for fewer
than the total number of bands.

MEAN (optional)
Use this keyword to specify an array that contains the image mean. MEAN is a (nb)
array where nb is equal to the number of bands in the file defined by FID.

STDV (optional)
Use this keyword to specify an array that contains the image standard deviation.
STDV is a (nb) array where nb is equal to the number of bands in the file defined by
FID.

Example
This example computes the statistics for a file using ENVI_STATS_DOIT and then
output the result to an ENVI statistics (.sta) file.
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
; Call the doit
envi_stats_doit, fid=fid, pos=pos, dims=dims, $
dmin=dmin, dmax=dmax, mean=mean, stdv=stdv, $
comp_flag=0, report_flag=1
; Save the results

ENVI Reference Guide

ENVI_WRITE_STATISTICS

530

Chapter 2: ENVI Routines


envi_write_statistics, test.sta, fid=fid, dmin=dmin, dmax=dmax,
$
mean=mean, stdv=stdv

See Also
ENVI_GET_STATISTICS
ENVI_STATS_DOIT

ENVI_WRITE_STATISTICS

ENVI Reference Guide

Chapter 2: ENVI Routines

531

FFT_DOIT
Use this program to perform forward Fast Fourier Transform of images.

Syntax
ENVI_DOIT, FFT_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

ENVI Reference Guide

FFT_DOIT

532

Chapter 2: ENVI Routines

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_fft_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; FFT on all samples and bands in
; the file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testfft
;
; Perform the FFT
;
envi_doit, fft_doit, $
fid=fid, pos=pos, dims=dims, $
out_name=out_name, r_fid=r_fid
;

FFT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

533

; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

FFT_DOIT

534

Chapter 2: ENVI Routines

FFT_INV_DOIT
Use this program to apply an FFT filter image and perform the inverse FFT.
Note
If a User Defined filter is selected, then the filter must exist as an ENVI
annotation file prior to starting this function.

Syntax
ENVI_DOIT, 'FFT_INV_DOIT'

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

FILTER_FID
Use this keyword to specify the file ID of a filter image generated by the
ENVI_FILTER_DOIT program.

FILTER_POS
Use this keyword to specify the band number for the filter image.

FFT_INV_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

535

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_DT
Use this keyword to specify the output file data type. OUT_DT should be an integer
value matching one of the standard IDL data types:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

ENVI Reference Guide

FFT_INV_DOIT

536

Chapter 2: ENVI Routines

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_fft_inv_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, testfft.img, r_fid=fid
envi_open_file, testfft.img, r_fid=f_fid
if (fid eq -1 or f_fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; inverse FFT on all samples and all
; bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
f_pos = [0]
;
; Perform the FFT
;
envi_doit, fft_inv_doit, $
fid=fid, pos=pos, dims=dims, $

FFT_INV_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

537

filter_fid=f_fid, filter_pos=f_pos, $
out_dt=4, out_name=out_name, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

FFT_INV_DOIT

538

Chapter 2: ENVI Routines

GAINOFF_DOIT
Use this program to apply a gain and offset to each input band.

Syntax
ENVI_DOIT, GAINOFF_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

GAIN
Set this keyword to an array of gain values, one for each element in POS.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OFFSET
Set this keyword to an array of offset values, one for each element in POS.

GAINOFF_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

539

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers ranging from zero
to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_gainoff_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; gain and offset correction on all
; samples and all bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
gain = [2.00, 1.33, 1.20, $
1.11, 2.60, 3.12]

ENVI Reference Guide

GAINOFF_DOIT

540

Chapter 2: ENVI Routines


offset = [12.33, 1.10, 6.00, $
1.55, 5.32, 4.05]
;
; Perform the emperical line calibration
;
envi_doit, gainoff_doit, $
fid=fid, pos=pos, dims=dims, $
gain=gain, offset=offset, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end
; Call the doit
gainoff_doit, fid=fid, pos=pos, dims=dims, out_name=out_name, $
gain=gain, offset=offset, r_fid=r_fid, in_memory=0
; Exit ENVI
envi_batch_exit
free_lun, lunit
end

GAINOFF_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

541

GEN_IMAGE_DOIT
Use this program to generate test images.

Syntax
ENVI_DOIT, GEN_IMAGE_DOIT

Keywords
DATA_TYPE
Use this keyword to specify the output data type.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

MAX_VAL
Use this keyword to specify the maximum value for methods 1,2,3 and 5.

MEAN
Use this keyword to specify the mean value for method 4.

METHOD
Set this keyword to specify which type of test image to generate. One of the
following:

0 Constant

1 Horizontal Ramp

2 Vertical Ramp

3 Random Noise (uniform)

4 Random Noise (normal)

5 Gaussian Point Spread Function

MIN_VAL
Use this keyword to specify the minimum value for methods 1,2,3 and 5.
ENVI Reference Guide

GEN_IMAGE_DOIT

542

Chapter 2: ENVI Routines

NB
Use this keyword to specify the number of bands in the output image.

NL
Use this keyword to specify the number of lines in the output image.

NS
Use this keyword to specify the number of samples in the output image.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

SEED (optional)
Use this keyword to specify an optional random number seed for methods 3 and 4.

SIGMA
Use this keyword to specify the gaussian sigma value for methods 4 and 5. For
method 5 +/- one sigma is equal to the number of samples.

VAL
Use this keyword to specify the constant value for Constant images.

Example
pro example_gen_image_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt

GEN_IMAGE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

543

;
; Set the keywords.
;
ns = 512L
nl = 512L
nb = 1
method = 3
min_val = 0
max_val = 1024
data_type = 2
out_name = testimg
;
; Generate the test image
;
envi_doit, gen_image_doit, $
ns=ns, nl=nl, nb=nb, method=method, $
min_val=min_val, max_val=max_val, $
data_type=data_type, out_name=out_name, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

GEN_IMAGE_DOIT

544

Chapter 2: ENVI Routines

HANDLE_VALUE
The HANDLE_VALUE procedure returns or sets the value of an existing handle.

Syntax
HANDLE_VALUE, ID, Value

Arguments
ID
A valid handle ID.

Value
When using HANDLE_VALUE to return an existing handle value (the default),
Value is a named variable in which the value is returned.
When using HANDLE_VALUE to set a handle value, Value is the new value. Note
that handle values can have any IDL data type and organization.

Keywords
NO_COPY
By default, HANDLE_VALUE works by making a second copy of the source data.
Although this technique is fine for small data, it can have a significant memory cost
when the data being copied is large.
If the NO_COPY keyword is set, HANDLE_VALUE works differently. Rather than
copy the source data, it takes the data away from the source and attaches it directly to
the destination. This feature can be used to move data very efficiently. However, it
has the side effect of causing the source variable to become undefined. On a retrieve
operation, the handle value becomes undefined. On a set operation, the variable
passed as Value becomes undefined.

SET
Set this keyword to assign Value as the new handle value. The default is to retrieve
the current handle value.

HANDLE_VALUE

ENVI Reference Guide

Chapter 2: ENVI Routines

545

Example
The following commands demonstrate the two different uses of HANDLE_VALUE:
; Retrieve the value of handle1 into the variable current.
HANDLE_VALUE, handle1, current
; Set the value of handle1 to a 2-element integer vector.
HANDLE_VALUE,handle1,[2,3],/SET

ENVI Reference Guide

HANDLE_VALUE

546

Chapter 2: ENVI Routines

HIST_EXPORT_DOIT
Use this routine to output an image using a supplied Lookup Table (LUT). A lookup
table is a method of changing input image DN to new output DN. The lookup table is
specified by the LUT keyword. Each input pixel is used to calculate the index into the
LUT, and the corresponding value in the LUT becomes the new output value. The
index into the LUT is calculated from the input data value, the input data minimum
(I_MIN), and the input binsize (I_BINSIZE) by the following formula:
Output value = LUT[(input value - I_MIN) / I_BINSIZE]

Additionally, the output DNs can be adjusted by the desired output minimum and
maximum, which are specified by the keywords O_MIN and O_MAX respectively.

Syntax
ENVI_DOIT, HIST_EXPORT_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

HIST_EXPORT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

547

LUT
Use this keyword to specify the lookup table array. The number of elements of LUT
is determined by the input data range and the input binsize, I_BINSIZE, using the
following formula:
# elements lut = (input data maximum - input data minimum) /
I_BINSIZE + 1

I_BINSIZE
Use this keyword to specify the input binsize. The binsize is the width in DN that a
group of input pixels will map to a single output pixel. For integer data, I_BINSIZE
must be an integer greater than or equal to one; for floating point data, I_BINSIZE
must be greater than zero.

I_MIN
Use this keyword to specify the input data minimum.

IN_MEMORY (optional)
Set this optional keyword to specify that output should be stored in memory. If
IN_MEMORY is not set, output will be stored on disk and OUT_NAME must be
specified. If IN_MEMORY is set, then OUT_NAME is not used.

O_MAX
Use this keyword to specify the desired output data maximum. O_MAX is a single
value with the same data type as OUT_DT.

O_MIN
Use this keyword to specify the desired output data minimum. O_MIN is a single
value with the same data type as OUT_DT.

OUT_BNAME (optional)
Use this optional keyword to specify a string array of output band names, if desired.

OUT_DT
Use this keyword to specify the output data type, using the following IDL
convention:

1 byte (8-bits)

ENVI Reference Guide

HIST_EXPORT_DOIT

548

Chapter 2: ENVI Routines

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify a single band position, which indicates the band number
on which to perform the operation. POS is a single long integer that ranges from zero
to (number of bands)-1.

R_FID (optional)
Use this optional keyword to specify a named variable that will contain the file ID for
the processed data. This file ID can be used to access the processed data. A valid file
ID is a long integer with a value greater than zero and an invalid file ID is specified as
-1.

Example
This example will calculate a new byte image using a square root lookup table. This
example uses the following files found in the DATA directory of the ENVI
installation:

bhtmref.img

bhtmref.hdr

HIST_EXPORT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

549

Since we have byte data and we do not want to change the dynamic range of the input
data, we will set the data minimums to zero and the data maximum to 255. We will
use a binsize of 1allowing each input pixel to map to its square root value. The
LUT must have 256 entries and the value of each entry is just the square root of the
index.
pro example_hist_export_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Setup the keywords to the
; processing routine
;
envi_file_query, fid, ns=ns, nl=nl, $
data_type=out_dt
out_name = testimg
dims = [-1, 0, ns-1, 0, nl-1]
pos = [0]
;
; Since we are converting byte data
; and do not wish to change the range
; of the input data we will set the
; data mins to 0 and the max to 255.
; An input binsize of one is used
; to map each input pixel to a
; output value.
;
o_min = 0
o_max = 255
i_min = 0
i_binsize = 1
lut = sqrt(lindgen(256))
;

ENVI Reference Guide

HIST_EXPORT_DOIT

550

Chapter 2: ENVI Routines


; Call the doit
;
envi_doit,hist_export_doit, fid=fid, $
pos=pos, dims=dims, out_name=out_name, $
out_dt=out_dt, i_min=i_min, o_min=o_min, $
o_max=o_max, lut=lut, i_binsize=i_binsize, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

HIST_EXPORT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

551

MAGIC_MEM_CHECK
MAGIC_MEM_CHECK is a memory management function. It should always be
called before the processing function. It returns a structure containing the tags
IN_MEMORY and OUT_NAME, which are then passed to the processing function
(doit).
If IN_MEMORY is set to zero, OUT_NAME is a string array containing a valid file
name. If IN_MEMORY is set to one, the user wishes to perform the operation in
memory. If IN_MEMORY is set to minus one, the OUT_NAME string may not be a
valid file name.

Syntax
Result = MAGIC_MEM_CHECK()

Keywords
DIMS
Use this keyword to specify a five-element array holding the data dimensions.The
elements are defined as follows:

DIMS[0]: a pointer to the ROI (set to -1 if no ROI is selected).

DIMS[1]: the starting X coordinate.

DIMS[2]: the ending X coordinate.

DIMS[3]: the starting Y coordinate.

DIMS[4]: the ending Y coordinate.

FID
Use this keyword to specify the file ID of the selected file.

IN_MEMORY
Use this keyword to specify the value of memory processing Typically,
IN_MEMORY is the in_memory tag name returned by the compound widget
WIDGET_OUTFM. If WIDGET_OUTFM is not used then set IN_MEMORY to one
when storing the result in memory and to zero otherwise.

ENVI Reference Guide

MAGIC_MEM_CHECK

552

Chapter 2: ENVI Routines

OUT_NAME
Use this keyword to specify the value of the output file name. Typically this is the
value returned from the compound widget WIDGET_OUTF or WIDGET_OUTFM.

OUT_DT
Use this keyword to specify the processing output image data type, using the
following IDL convention:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

NB
Use this keyword to specify the number of bands in the output image.

Example
After getting the processing parameters call MAGIC_MEM_CHECK to make sure
that in memory items will not exceed the total cache size. After calling
MAGIC_MEM_CHECK use the values stored in M_RES.IN_MEMORY and
M_RES.OUT_NAME for the in memory processing flag or the output filename. if
M_RES.CANCEL is set then the user has canceled the operation.
m_res=magic_mem_check(fid=fid,dims=dims, out_dt=1,$
nb=n_elements(pos), out_name=result.outf.name,$
in_memory=result.outf.in_memory)
if (m_res.cancel) then return
in_memory = m_res.in_memory
out_name = m_res.out_name

MAGIC_MEM_CHECK

ENVI Reference Guide

Chapter 2: ENVI Routines

553

MATCH_FILTER_DOIT
Use this program to perform match filtering.

Syntax
ENVI_DOIT, MATCH_FILTER_DOIT

Keywords
COV
Use this keyword to specify the input data covariance matrix. Typically this is the
covariance of the data with the optional mask applied.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

ENDMEM
Use this keyword to specify the endmembers array. ENDMEM is a floating point
array (nb, # end members).

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

ENVI Reference Guide

MATCH_FILTER_DOIT

554

Chapter 2: ENVI Routines

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

MEAN
Use this keyword to specify the input data mean. Typically this is the mean of the
data with the optional mask applied.

M_FID
Use this keyword to specify the file ID for the mask file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

M_POS
Use this keyword to specify the band position of the mask band. M_POS is a single
long value greater than or equal to zero.

O_MAX
Use this keyword to specify the output data maximum to use for conversion to byte.
O_MAX is only used when the output data type, OUT_DT, is set to 1 (byte).

O_MIN
Use this keyword to specify the output data minimum to use for conversion to byte.
O_MIN is only used when the output data type, OUT_DT, is set to 1 (byte).

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_DT
Use this keyword to specify the output file data type. OUT_DT should be an integer
value matching the IDL data type: 1-byte or 4-float.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

MATCH_FILTER_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

555

POS
Use this keyword to specify a one-dimensional array of band positions indicating the
band numbers on which to perform the operations. POS is a long array ranging from
0 to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_match_filter_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, mof94av.bil, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS and POS to keywords
; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
envi_file_query, fid, ns=ns, nl=nl, $
nb=nb
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Read in the endmember text file.
; The first column are the
; wavelengths and the next 19
; columns are the endmembers. We will

ENVI Reference Guide

MATCH_FILTER_DOIT

556

Chapter 2: ENVI Routines


; use the 19 endmembers for MF.
; The endmember data must also be
; transposed in order to send in
; a (nb, # endmember) array.
;
envi_read_cols, m94_em.asc, $
endmem, skip=em_names, /read_skip
endmem = transpose(endmem[1:*,*])
out_bname = em_names[2:*]
;
; Calculate the covariance of the
; input data file.
;
envi_doit, envi_stats_doit, $
fid=fid, pos=pos, dims=dims, $
mean=mean, cov=cov, comp_flag=5
;
; Call the match filter processing
; routine.
;
envi_doit,match_filter_doit, $
fid=fid, pos=pos, dims=dims, $
mean=mean, cov=cov, endmem=endmem, $
out_dt=4, out_name=out_name, $
out_bname=out_bname, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

MATCH_FILTER_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

557

MATCH_FILTER_MT_DOIT
Use this program to perform mixture tuned matched filtering. Compute both the
normal matched filter as well as the mixture tuned matched filter infeasibility answer
for each endmember.

Syntax
ENVI_DOIT, MATCH_FILTER_MT_DOIT

Keywords
COV
Use this keyword to specify the input data covariance matrix. Typically this is the
covariance of the data with the optional mask applied.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

ENDMEM
Use this keyword to specify the endmembers array. ENDMEM is a floating point
array (nb, # end members).

EVAL
Use this keyword to specify the input data eigen values. Typically this is the eigen
values of the data with the optional mask applied.

ENVI Reference Guide

MATCH_FILTER_MT_DOIT

558

Chapter 2: ENVI Routines

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

MEAN
Use this keyword to specify the input data mean. Typically this is the mean of the
data with the optional mask applied.

M_FID
Use this keyword to specify the file ID for the mask file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

M_POS
Use this keyword to specify the band position of the mask band. M_POS is a single
long value greater than or equal to zero.

O_MAX
Use this keyword to specify the output data maximum to use for conversion to byte.
O_MAX is only used when the output data type, OUT_DT, is set to 1 (byte).

O_MIN
Use this keyword to specify the output data minimum to use for conversion to byte.
O_MIN is only used when the output data type, OUT_DT, is set to 1 (byte).

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_DT
Use this keyword to specify the output file data type. OUT_DT should be an integer
value matching the IDL data type: 1-byte or 4-float.

MATCH_FILTER_MT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

559

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify a one-dimensional array of band positions indicating the
band numbers on which to perform the operations. POS is a long array ranging from
0 to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_match_filter_mt_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, mof94av.bil, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS and POS to keywords
; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
envi_file_query, fid, ns=ns, nl=nl, $
nb=nb
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg

ENVI Reference Guide

MATCH_FILTER_MT_DOIT

560

Chapter 2: ENVI Routines


;
; Read in the endmember text file.
; The first column are the
; wavelengths and the next 19
; columns are the endmembers. We will
; use the 19 endmembers for MTFM.
; The endmember data must also be
; transposed in order to send in
; a (nb, # endmember) array.
;
envi_read_cols, m94_em.asc, $
endmem, skip=em_names, /read_skip
endmem = transpose(endmem[1:*,*])
out_bname = [$
MF Score ( + em_names[2:*] + ), $
Infeasibility ( + em_names[2:*] + )]
;
; Calculate the statistics for the
; input data file.
;
envi_doit, envi_stats_doit, $
fid=fid, pos=pos, dims=dims, $
mean=mean, cov=cov, eval=eval, $
evec=evec, comp_flag=5
;
; Call the match filter processing
; routine.
;
envi_doit,match_filter_mt_doit, $
fid=fid, pos=pos, dims=dims, $
mean=mean, cov=cov, eval=eval, $
evec=evec, endmem=endmem, $
out_dt=4, out_name=out_name, $
out_bname=out_bname, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

MATCH_FILTER_MT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

561

MATH_DOIT
Use this program to perform mathematical operations on image data.

Syntax
ENVI_DOIT, MATH_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

EXP
Use this keyword to specify the math expression to perform. EXP is a string variable.

FID
Use this keyword to specify an array of file IDs, one for each of the bands in EXP.
FID is a long integer array.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

ENVI Reference Guide

MATH_DOIT

562

Chapter 2: ENVI Routines

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions corresponding to the band
location for each of the bands in EXP, POS is a long integer array.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Notes
Some valid ENVI math expressions are:
EXP
EXP
EXP
EXP
EXP
EXP

=
=
=
=
=
=

b1+b1
byte ((float(b1)+float(b2))<255)
byte(((floatt(b1)+float(b2)+float(b3))/3.0)
(sin(b1)^2+cos(b2))*tan(b3)
b1 and b2
b1 xor b2

Example
pro example_math_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;

MATH_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

563

; Set the keywords. We will perform the


; band math on all samples in the file.
;
envi_file_query, fid, ns=ns, nl=nl
t_fid = [fid,fid]
dims = [-1, 0, ns-1, 0, nl-1]
pos = [0,1]
exp = b1 + b2
out_name = testimg
;
; Perform the band math processing
;
envi_doit, math_doit, $
fid=t_fid, pos=pos, dims=dims, $
exp=exp, out_name=out_name, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

MATH_DOIT

564

Chapter 2: ENVI Routines

MNF_DOIT
Use this program to perform a Minimum Noise Fraction (MNF) transform.

Syntax
ENVI_DOIT, MNF_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

NO_PLOT (optional)
Set this optional keyword to disable the resulting Principal Components eigenvalue
plot. When this keyword is set the eigenvalues will not be sent to a plot window.

MNF_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

565

NOISE_EVEC
Use this keyword to specify the noise eigen vectors. NOISE_EVEC is not needed if
keyword SHIFT_DIFF is set.

NOISE_EVAL
Use this keyword to specify the noise eigen values. NOISE_EVAL is not needed if
keyword SHIFT_DIFF is set.

NOISE_STA_NAME
Use this keyword to specify the noise statistics file.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OUT_NB (optional)
Use this keyword to specify the number of output bands in the MNF image.
OUT_NB is a long integer ranging from one to the number of elements of POS. The
default is to use the number of bands specified by POS.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

QUERY (optional)
Set this keyword to specify that the number of output bands be selected interactively
from the eigenvalues.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

ENVI Reference Guide

MNF_DOIT

566

Chapter 2: ENVI Routines

SD_DIMS
Use this keyword to specify the spatial dimensions for the shift differencing
operation. SD_DIMS only needs to be set if the keyword SHIFT_DIFF is set.
SD_DIMS is a five-element array of long integers with the following definitions:

DIMS[0]: A pointer to the region of interest. Set to -1 for non ROI items.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

SHIFT_DIFF
Set this keyword to specify that noise statistics be computed by shift differencing.

STA_NAME
Use this keyword to specify the statistics file name.

Example
pro example_mnf_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords DIMS and POS to
; process all spatial and all spectral
; data.
;

MNF_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

567

envi_file_query, fid, ns=ns, nl=nl, nb=nb


dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Call the MNF processing routine
; use the shift difference method
; to calculate the noise statistics.
; Output the result to a disk file,
; set the statistics file to a null
; file and do not plot the eigenvalues.
;
envi_doit, mnf_doit, $
fid=fid, pos=pos, dims=dims, $
sd_dims=dims, out_name=out_name, $
in_memory=0, sta_name=, /no_plot, $
shift_diff=1, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

MNF_DOIT

568

Chapter 2: ENVI Routines

MNF_INV_DOIT
Use this program to perform an inverse Minimum Noise Fraction (MNF) transform.
To use the MNF as a filter, first perform a forward MNF without reducing the output
number of band. Next, perform the inverse MNF and specify only the number of
bands to include in the inverse using the POS keyword.

Syntax
ENVI_DOIT, MNF_INV_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

MNF_INV_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

569

OUT_DT
Use this keyword to specify the inverse MNF output data type.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

STA_NAME
Use this keyword to specify the forward MNF statistics filename. The number of
bands output from the inverse MNF is based on the number of bands in the
STA_NAME statistics file.

See Also
MNF_DOIT

ENVI Reference Guide

MNF_INV_DOIT

570

Chapter 2: ENVI Routines

MORPH_DOIT
Use this program to perform morphological filtering including dilatation, erosion,
opening, closing.

Syntax
ENVI_DOIT, MORPH_DOIT

Keywords
CYCLES
Use this keyword to specify the integer number of cycles to perform the
morphological operation.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

GRAY
Set this keyword to perform grayscale, rather than binary operations. Nonzero
elements of the kernel parameter determine the shape of the structuring element
(neighborhood). If values is not present, all elements of the structuring element are 0,
yielding the neighborhood minimum operator for erosion and the maximum operator
for dilation.
MORPH_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

571

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

KERNEL
Use this keyword to specify a structuring element for the morphological process. The
elements are interpreted as binary values, either zero or nonzero.

METHOD
Set this keyword to one of the following values to indicates the type of filter to apply:

0 erosion

1 dilation

2 opening

3 closing

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

ENVI Reference Guide

MORPH_DOIT

572

Chapter 2: ENVI Routines

VALUE
An array of the same dimensions as kernel providing the values of the structuring
element. The presence of this keyword implies grayscale erosion. Each element in the
structuring element is either subtracted (erosion) or added (dilation) to the associated
pixels. The minimum (erosion) or maximum (dilation) is performed.

Example
pro example_morph_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; morphological filtering on all
; samples and all bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
kernel = fltarr(5,5) + 1.
value = kernel
out_name = testimg
;
; Perform the morphological
; opening filter operation
; on the image.
;
envi_doit, morph_doit, $
fid=fid, pos=pos, dims=dims, $
method=2, gray=1, kernel=kernel, $
value=value, cycles=3, $

MORPH_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

573

out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

MORPH_DOIT

574

Chapter 2: ENVI Routines

MOSAIC_DOIT
Use this routine to overlay two or more images that have overlapping areas (typically
georeferenced) or to put together a variety of non-overlapping images (typically
pixel-based). Individual bands, entire files, and multi-resolution georeferenced
images can be mosaicked and will be automatically resampled. The location of each
mosaicked input file is specified using the x0 and y0 keywords. The values to x0 and
y0 are in pixels and may require the user to convert the output pixel location for
georeferenced images.

Syntax
ENVI_DOIT, MOSAIC_DOIT

Keywords
BACKGROUND
Use this keyword to specify the output image background value. All pixels outside
the image boundary will be set to the value specified by BACKGROUND.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a long integer array [5,#input files] with the following
definitions:

DIMS[0,*]: Unused for this function, set to -1.

DIMS[1,*]: The starting X pixel. (The first pixel is number zero.)

DIMS[2,*]: The ending X pixel.

DIMS[3,*]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4,*]: The ending Y pixel.

FID
Use this keyword to specify a long-integer array of file IDsone for each file to
mosaic. The file ID is the value returned by the R_FID keyword to the
ENVI_OPEN_FILE procedure or the FID keyword to ENVI_SELECT.

MOSAIC_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

575

GEOREF (optional)
Set this keyword to indicate that the data is georeferenced. If the data is
georeferenced, the MAP_INFO keyword must be defined.

IN_MEMORY (optional)
Set this optional keyword to specify that output should be stored in memory. If
IN_MEMORY is not set, output will be stored on disk and OUT_NAME must be
specified. If IN_MEMORY is set then OUT_NAME is not used.

MAP_INFO (optional)
Use this optional keyword to specify map information. Set MAP_INFO equal to the
structure returned from ENVI_GET_MAP_INFO or ENVI_MAP_INFO_CREATE.

OUT_BNAME (optional)
Use this optional keyword to specify a string array of output band names, if desired.

OUT_DT
Use this keyword to specify a named variable that will contain the IDL data type of
the file, using the following IDL convention:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

ENVI Reference Guide

MOSAIC_DOIT

576

Chapter 2: ENVI Routines

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

PIXEL_SIZE
Use this keyword to specify a two-element floating point or double precision array
containing the X and Y pixel sizes, respectively. For pixel-based mosaics set the X
and Y pixel sizes to one: PIXEL_SIZE=[1.,1.]

POS
Use this keyword to specify a long-integer array of band positions to be included in
the mosaic. The dimensions of the array must be [#output bands, #files]. The value of
minus one (-1) in the POS array is used to indicate that no input band for the
associated file is included in the corresponding mosaicked output band. The valid
values for POS are 0 to #number of bands (for the corresponding file) plus the value
of minus one (-1).

R_FID (optional)
Use this optional keyword to specify a named variable that will contain the file ID for
the processed data. This file ID can be used to access the processed data.

SEE_THROUGH_VAL (optional)
Use this optional keyword to set the see-through value for each input file.
SEE_THROUGH_VAL is an array of values with the same data type as OUT_DT
and has [#files] elements. If a pixel in the input file is equal to its corresponding value
of SEE_THROUGH_VAL then that pixel is not transferred to the output mosaic,
which allows data stacked underneath to remain visible. If any elements of the array
USE_SEE_THROUGH are equal to 1 then the SEE_THROUGH_VAL array must
be specified.

USE_SEE_THROUGH
Use this keyword to specify an integer array of zeros and ones indicating whether the
bands from the current file will use the corresponding SEE_THROUGH_VAL value.
A 1 indicates that the input file will use SEE_THROUGH_VAL and a 0 indicates
that SEE_THROUGH_VAL will not be used. The number of elements in the
USE_SEE_THROUGH array is equal to the number of input files specified by FID.

MOSAIC_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

577

XSIZE
Use this keyword to set the X size of the output image (sample direction). For pixelbased mosaics the XSIZE is in pixels and the corresponding pixels size is [1,1]. For
georeferenced images XSIZE is in the same units as PIXEL_SIZE. For example, a 1
Km image in the sample direction would use a pixel size of one meter and a XSIZE
of 1000 meters.

x0
Use this keyword to specify a long-integer array of X starting pixels, one for each
file. x0 is in pixel coordinates and may require the conversion of map locations for
georeferenced image to output pixel locations.

YSIZE
Use this keyword to set the Y size of the output image (line direction). For pixel
based mosaics the YSIZE is in pixels and the corresponding pixel size is [1,1]. For
georeferenced images YSIZE is in the same units as PIXEL_SIZE. For example, a 1
Km image in the line direction would use a pixel size of one meter and a YSIZE of
1000 meters.

y0
Use this keyword to specify a long-integer array of Y starting linesone for each
file. y0 is in pixel coordinates and may require the conversion of map locations for
georeferenced image to output line locations.

Example
This example mosaics the first three bands from bhtmref.img and the single band
bhdemsub.img side by side into the same output image (pixel-based). This example
uses the following files found in the DATA directory of the ENVI installation:

bhtmref.img

bhtmref.hdr

bhtdemsub.img

bhtdemsub.hdr

The single band DEM will only be placed into the first output band while the TM
data will be placed into all three output bands. The data are positioned with a 20-pixel
border around the outside and between each of the images. The actual border area
will vary because the images are not the same size and the DEM image is only in the
ENVI Reference Guide

MOSAIC_DOIT

578

Chapter 2: ENVI Routines

first output band. We will use the background value of 255 for the border area. Set the
output data type to integer since that is the greater of the two data types. The images
are mosaicked side by side so no see-through is needed, but for illustration purposes
set see-through to zero for each of the input files.
pro example_mosaic_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input files
;
envi_open_file, bhtmref.img, r_fid=tm_fid
if (tm_fid eq -1) then begin
envi_batch_exit
return
endif
envi_open_file, bhdemsub.img, r_fid=dem_fid
if (dem_fid eq -1) then begin
envi_batch_exit
return
endif
;
; Build the necessary keywords. We will
; create a new 3 band output image from
; a pixel mosaic of the first three band
; of the TM data and the single band DEM.
;
envi_file_query, tm_fid, ns=tm_ns, nl=tm_nl
envi_file_query, dem_fid, ns=dem_ns, nl=dem_nl
fid = [tm_fid, dem_fid]
pos = [[0,1,2],[0,-1,-1]]
dims = [[-1,0, tm_ns-1,0, tm_nl-1], $
[-1,0,dem_ns-1,0,dem_nl-1]]
out_name = testimg
;
; Determine the placement of the output
; bands. The upper left corner of the
; TM data is at [20,20] and the upper
; lefter corner of the DEM data is [40+tm_ns, 20]
;
x0 = [20,40+tm_ns]
y0 = [20,20]

MOSAIC_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

579

xsize = tm_ns + dem_ns + 60


ysize = (tm_nl > dem_nl) + 40
pixel_size = [1.,1.]
;
; Although it does not matter (since
; we are placing the files next to each
; other) we will use a see through
; value of zero for each file.
;
use_see_through = [1L,1]
see_through_val = [0L,0]
;
; Call the doit. Use a background value of
; 255 and set the output data type to
; integer.
;
envi_doit, mosaic_doit, fid=fid, pos=pos, $
dims=dims, out_name=out_name, xsize=xsize, $
ysize=ysize, x0=x0, y0=y0, georef=0, $
out_dt=2, pixel_size=pixel_size, $
background=255, see_through_val=see_through_val, $
use_see_through=use_see_through
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

MOSAIC_DOIT

580

Chapter 2: ENVI Routines

MSSCAL_DOIT
Use this program to calibrate MSS data to radiance or reflectance using pre-launch
characteristics.

Syntax
ENVI_DOIT, MSSCAL_DOIT

Keywords
CAL_TYPE
Use this keyword to specify the calibration type. Set CAL_TYPE equal to zero to
indicate Radiance or to one to indicate Reflectance.

DATE
Use this keyword to specify the calibration numbers to use, depending on the satellite
and the date the data was collected. The default value for DATE is zero. Choose one
of the following:
Landsat 2

0 - Before July 16, 1975

1 - After July 16, 1975

Landsat 3

0 - Before June 1, 1978

1 - After June 1, 1978

Landsat 4

0 - Before August 26, 1982

1 - Between August 26, 1982 and March 31, 1983

2 - After March 31, 1983

Landsat 5

0 - Before April 6, 1982

1 - Between April 6, 1982 and November 8, 1984

2 - After November 8, 1984

MSSCAL_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

581

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

QCAL_DATE
Set this keyword for Landsat 1, Landsat 2, or Landsat 3 MSS data collected before
February 1, 1976, and for Landsat 4 MSS data collected before October 22, 1982.
Leave QCAL_DATE unset for all other data.

ENVI Reference Guide

MSSCAL_DOIT

582

Chapter 2: ENVI Routines

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

SAT
Set this keyword to one of the following values to indicate the satellite type:

1 Landsat 1

2 Landsat 2

3 Landsat 3

4 Landsat 4

5 Landsat 5

SUN_ANGLE
Use this keyword to specify a floating-point value between 0.0 and 90.0
corresponding to the sun elevation angle. Sun elevation is only used for reflectance
calibration.

Example
pro example_msscal_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; MSS calibration on all samples
; and all bands in the file.

MSSCAL_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

583

;
envi_file_query, fid, ns=ns, nl=nl
dims = [-1, 0, ns-1, 0, nl-1]
pos = [0,1,2,3]
out_name = testimg
;
; Perform the MSS calibration
;
envi_doit, msscal_doit, $
fid=fid, pos=pos, dims=dims, $
date=2, sat=4, sun_angle=76., $
cal_type=1, qcal_date=0, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

MSSCAL_DOIT

584

Chapter 2: ENVI Routines

MUNSELL_DOIT
Use this program to calculate the USGS Munsell Coordinates (HSV) from an RGB
image.

Syntax
ENVI_DOIT, MUNSELL_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify a three-element long-integer array of file IDs for the
selected bands. The three elements represent the red, green, and blue bands,
respectively.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

MUNSELL_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

585

POS
Use this keyword to specify a three-element long-integer array of band positions.
Elements of POS are paired with elements of the FID array.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_munsell_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; munsell transform on all samples
; and first three bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl
t_fid=[fid,fid,fid]
dims = [-1, 0, ns-1, 0, nl-1]
pos = [0,1,2]
out_name = testmunsell.img
;
; Perform the Munsell transform
;
envi_doit, munsell_doit, $
fid=t_fid, pos=pos, dims=dims, $
out_name=out_name, r_fid=r_fid
;

ENVI Reference Guide

MUNSELL_DOIT

586

Chapter 2: ENVI Routines


; Exit ENVI
;
envi_batch_exit
end

MUNSELL_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

587

MUNSELL_INV_DOIT
Use this program to calculate an RGB image from USGS Munsell coordinates
(HSV).

Syntax
ENVI_DOIT, MUNSELL_INV_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify a three-element long-integer array of file IDs for the
selected bands. The three elements represent the red, green, and blue bands,
respectively.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

ENVI Reference Guide

MUNSELL_INV_DOIT

588

Chapter 2: ENVI Routines

POS
Use this keyword to specify a three-element long-integer array of band positions.
Elements of POS are paired with elements of the FID array.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_munsell_inv_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, testmunsell.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; munsel transform on all samples
; and the first three bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl
t_fid=[fid,fid,fid]
dims = [-1, 0, ns-1, 0, nl-1]
pos = [0,1,2]
out_name = testimg
;
; Perform the Munsell transform
;
envi_doit, munsell_inv_doit, $
fid=t_fid, pos=pos, dims=dims, $
out_name=out_name, r_fid=r_fid
;

MUNSELL_INV_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

589

; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

MUNSELL_INV_DOIT

590

Chapter 2: ENVI Routines

NDVI_DOIT
Use this program to create a Normalized Difference Vegetation Index (NDVI).

Syntax
ENVI_DOIT, NDVI_DOIT

Keywords
CHECK
Set this keyword to check for divide by zero errors. Any divide by zero errors are set
to zero.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

NDVI_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

591

O_MAX
Use this keyword to specify the output data maximum. This keyword is only used
when OUT_DT is set to byte.

O_MIN
Use this keyword to specify the output data minimum. This keyword is only used
when OUT_DT is set to byte.

OUT_DT
Use this keyword to specify the output data type, either 1 for byte or 4 for floating
point. All other output data types are invalid.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

POS
Use this keyword to specify an array of zero based two band positions. NDVI is
designed to work with TM, MSS, AVHRR, SPOT, and AVIRIS DATA. The following
band pairs are used for each of the different data types.
Data Type

Band Numbers (one based, [IR, Red])

TM

Bands= [4,3]

MSS

Bands = [7, 5]

AVHRR

Bands = [2, 1]

SPOT XS

Bands = [3, 2]

AVIRIS

Bands = [51, 29]


Table 31-6: Data Types and Band Numbers

Make sure to subtract one from each of the band combinations listed in the table.

ENVI Reference Guide

NDVI_DOIT

592

Chapter 2: ENVI Routines

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_ndvi_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; NDVI on all samples and all bands
; in the file.
;
envi_file_query, fid, ns=ns, nl=nl
dims = [-1, 0, ns-1, 0, nl-1]
pos = [4,3] - 1
out_name = testimg
;
; Perform the NDVI transform
;
envi_doit, ndvi_doit, $
fid=fid, pos=pos, dims=dims, $
/check, o_min=0, o_max=255, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

NDVI_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

593

ON_IOERROR
The ON_IOERROR procedure specifies a statement to be jumped to if an I/O error
occurs in the current procedure. Normally, when an I/O error occurs, an error
message is printed and program execution is stopped. If ON_IOERROR is called and
an I/O related error later occurs in the same procedure activation, control is
transferred to the designated statement with the error code stored in the system
variable !ERROR_STATE. The text of the error message is contained in
!ERROR_STATE.MSG.
The effect of ON_IOERROR can be canceled by using the label NULL in the call.
Note
Calls to ON_IOERROR made in the procedure that causes an I/O error supersede
any error handling mechanisms created with CATCH and the program branches to
the label specified by ON_IOERROR.

Syntax
ON_IOERROR, Label

Arguments
Label
The label name the program jumps to when an I/O error is encountered.

ENVI Reference Guide

ON_IOERROR

594

Chapter 2: ENVI Routines

PC_ROTATE
Use this program to calculate the Principal Components Rotation transform.

Syntax
ENVI_DOIT, PC_ROTATE

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

EVEC
Use this keyword to specify the eigen vectors.

EVAL
Use this keyword to specify the noise eigen values.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

FORWARD
Set this keyword to specify that PC_ROTATE perform a Forward Principal
Components Rotation otherwise the Inverse rotation is performed.

PC_ROTATE

ENVI Reference Guide

Chapter 2: ENVI Routines

595

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

MEAN
Use this keyword to specify the mean of each band.

NO_PLOT (optional)
Set this optional keyword to disable the resulting Principal Components eigenvalue
plot. When this keyword is set the eigenvalues will not be sent to a plot window.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_DT
Use this keyword to specify the output data type for the Principle Components
Rotation. Valid values of OUT_DT are byte, float or double. Use the IDL convention
when specifying OUT_DT (1=byte, 4=float, 5=double).

OUT_NB (optional)
Use this optional keyword to specify the output number of bands for the Principal
Components. The value must be less that than the number of elements of POS and the
default is the number of elements of POS. Only the first OUT_NB bands are stored in
the result ENVI file.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.
ENVI Reference Guide

PC_ROTATE

596

Chapter 2: ENVI Routines

Example
PRO example_pc_rotate
;
; First restore all the base save files.
;
;ENVI, /RESTORE_BASE_SAVE_FILES
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt.
;
;ENVI_BATCH_INIT, LOG_FILE = batch.txt
;
; Open the input file.
;
file = ENVI_PICKFILE(TITLE = mof94av.bil, FILTER = *.bil)
envi_open_file, file, r_fid=fid
;ENVI_OPEN_FILE, mof94av.bil, R_FID = fid
IF (fid EQ -1) THEN BEGIN
ENVI_BATCH_EXIT
RETURN
ENDIF
;
; Set the DIMS and POS to keywords
; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
ENVI_FILE_QUERY, fid, NS = ns, NL = nl, $
NB = nb
dims = [-1L, 0, ns - 1, 0, nl - 1]
pos = LINDGEN(nb)
out_name = testimg
;
; Calculate the statistics for the
; input data file.
;
ENVI_DOIT, ENVI_STATS_DOIT, $
FID = fid, POS = pos, DIMS = dims, $
MEAN = avg, EVAL = eval, EVEC = evec, $
COMP_FLAG = 5
;
; Call the Principal Components
; processing routine.
;
ENVI_DOIT, PC_ROTATE, $
FID = fid, POS = pos, DIMS = dims, $
MEAN = avg, EVAL = eval, EVEC = evec, $

PC_ROTATE

ENVI Reference Guide

Chapter 2: ENVI Routines

597

OUT_DT = 4, OUT_NAME = out_name, $


OUT_NB = nb, R_FID = r_fid, $
/FORWARD
;
; Exit ENVI.
;
;ENVI_BATCH_EXIT
END

ENVI Reference Guide

PC_ROTATE

598

Chapter 2: ENVI Routines

PPI_DOIT
Use this program to calculate the Pixel Purity IndexTM for an image.

Syntax
ENVI_DOIT, PPI_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to 1s.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as 1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

ITERATIONS
Use this keyword to specify the total number of iterations for run. If using a previous
PPI_DOIT output then ITERATIONS specifies the additional number of iterations to
run.

PPI_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

599

OUT_BNAME
Use this keyword to specify a string array for the output band name, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

P_FID
Use this keyword to specify the file ID for a previous output file from the PPI_DOIT.
If not using a previous PPI_DOIT file then P_FID must be set to -1.

POS
Use this keyword to specify a three-element long-integer array of band positions.
Elements of POS are paired with elements of the FID array.

PREV_ITER
Use this keyword to specify the previous number of iterations performed on the data.
PREV_ITER must be set to zero if the data is not restarting a previous processing
cycle.

PREV_DATA
Use this keyword to specify an array of the previous Total Pixel Counts. This data is
stored in a .cnt file from the previous run.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

THRESH
Use this keyword to specify the threshold factor.

Example
pro example_ppi_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files

ENVI Reference Guide

PPI_DOIT

600

Chapter 2: ENVI Routines


;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, mof94av.bil, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS and POS to keywords
; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
envi_file_query, fid, ns=ns, nl=nl, $
nb=nb
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Call the PPI processing
;
envi_doit,ppi_doit, $
fid=fid, pos=pos, dims=dims, $
p_fid=-1, iterations=10000, $
thresh=3.0, prev_iter=0, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

PPI_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

601

RADAR_INC_ANGLE_DOIT
Use this program to calculate an incidence angle for a radar image. No DEM data is
used in the calculation of the incidence angle.

Syntax
ENVI_DOIT, RADAR_INC_ANGLE_DOIT

Keywords
DEGREES (optional)
Set this keyword to specify that the input and output angles are in degrees. Otherwise
the angles are assumed to be in radians.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FR_ANGLE
Use this keyword to specify the far range angle for the locations specified by the
DIMS array.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

ENVI Reference Guide

RADAR_INC_ANGLE_DOIT

602

Chapter 2: ENVI Routines

NR_ANGLE
Use this keyword to specify the near range angle for the locations specified by the
DIMS array.

LEFT_LOOK
Set this keyword to use a left looking instrument to calculate the incidence angle
image.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

RANGE_DIR
Use this keyword to specify the range direction.RANGE_DIR is an integer value
with the following definitions:

0 Range by samples

1 Range by lines

Example
pro example_radar_inc_angle_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the keywords.
;
ns = 512L
nl = 512L
dims = [-1, 0, ns-1, 0, nl-1]
nr_angle = 20.5

RADAR_INC_ANGLE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

603

fr_angle = 28.0
range_dir = 0
out_name = testimg
;
; Generate the radar incidence angle
; image.
;
envi_doit, radar_inc_angle_doit, $
dims=dims, nr_angle=nr_angle, $
fr_angle=fr_angle, range_dir=range_dir, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

RADAR_INC_ANGLE_DOIT

604

Chapter 2: ENVI Routines

RATIO_DOIT
Use this program to calculate ratios of selected image bands.

Syntax
ENVI_DOIT, RATIO_DOIT

Keywords
CHECK
Set this keyword to check for divide by zero errors. Any divide by zero errors are set
to zero.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify a one-dimension array of file IDs for the ratio pairs. Each
pair is sequential in the list, i.e. (0,1) (2,3) (4,5) etc. FID is a long integer array.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

O_MAX
Use this keyword to specify the output data maximum. This keyword is only used
when OUT_DT is set to byte.

RATIO_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

605

O_MIN
Use this keyword to specify the output data minimum. This keyword is only used
when OUT_DT is set to byte.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_DT
Use this keyword to specify the output data type, either 1 for byte or 4 for floating
point. All other output data types are invalid.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify a one-dimension array of band positions for the ratios.
POS is an array of long integers, ranging from zero to two times the number of pairs.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_ratio_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit

ENVI Reference Guide

RATIO_DOIT

606

Chapter 2: ENVI Routines


return
endif
;
; Set the DIMS keywords to processes
; all spatial data. Use the POS
; keyword to ratio bands 1 and 4.
; Output the result to disk.
;
envi_file_query, fid, ns=ns, nl=nl
t_fid=[fid,fid]
dims = [-1, 0, ns-1, 0, nl-1]
pos = [1,4]
out_name = testimg
;
; Perform the ratio calculation
;
envi_doit, ratio_doit, $
fid=t_fid, pos=pos, dims=dims, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

RATIO_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

607

RESIZE_DOIT
Use this program to spatially resize image data.

Syntax
ENVI_DOIT, RESIZE_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

INTERP
Use this keyword to specify an integer value corresponding to the interpolation type.
Choose one of the following.

0 Nearest Neighbor

1 Bilinear

ENVI Reference Guide

RESIZE_DOIT

608

Chapter 2: ENVI Routines

2 Cubic Convolution

3 Pixel Aggregate

Note
Bilinear and cubic convolution interpolation methods do not apply when
downsampling data. Either nearest neighbor interpolation or pixel aggregate
interpolation should be used when downsampling data. If bilinear interpolation
(INTERP = 1) or cubic convolution interpolation (INTERP = 2) is specified while
downsampling, RESIZE_DOIT will default to the nearest neighbor method.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

RFACT
Use this keyword to specify a two-element array holding the rebin factors for X and
Y. The values of RFACT reflect the IDL convention for resizing data. A value of one
does not change the size of the data. Values less than one cause the size to increase,
values greater than one cause the size to decrease.

Example
pro example_resize_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files

RESIZE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

609

;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS and POS to keywords
; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Perform the resize calculation.
; Make the output image twice as
; large in both X and Y. Use
; bilinear interpolation.
;
envi_doit, resize_doit, $
fid=fid, pos=pos, dims=dims, $
interp=1, rfact=[.5,.5], $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

RESIZE_DOIT

610

Chapter 2: ENVI Routines

RGB_GET_BANDS
This procedure brings up an ENVI Band Selection dialog that allows the user to
select three bands from the Available Bands List.
Note
An interactive ENVI session is required to run this routine.

Syntax
RGB_GET_BANDS

Keywords
DIMS
Use this keyword to specify a named variable that will contain a five-element array
holding the data dimensions. The elements are defined as follows:

DIMS[0]: a pointer to the ROI (set to -1 if no ROI is selected).

DIMS[1]: the starting X coordinate.

DIMS[2]: the ending X coordinate.

DIMS[3]: the starting Y coordinate.

DIMS[4]: the ending Y coordinate.

FID
Use this keyword to specify a named variable that will contain the file IDs of the
selected files. FID will be an long array of three.

NO_DIMS (optional)
Set this optional keyword to disable spatial subsetting on the selected RGB bands.

POS
Use this keyword to specify a named variable that will contain a three-element array
of the selected band positions.

RGB_GET_BANDS

ENVI Reference Guide

Chapter 2: ENVI Routines

611

STR (optional)
Use this optional keyword to specify a string array containing the labels for the text
boxes used to enter the three band names. The default value for the array is [R,
G, B].

TITLE
Use this keyword to specify the string used in the title bar of the Band Selection
dialog window. Enter the title enclosed in single quotes.

Example
This examples uses an RGB selection widget titled USGS Munsell RGB to HSI Input
File to select three bands. The resulting selection is returned in FID, POS and DIMS.
tstr = USGS Musell RGB to HSI Input File
rgb_get_bands, title=tstr, fid=fid, pos=pos, dims=dims
if (fid[0] eq -1) then return

Notes
If fid(0) = -1, the Cancel button was selected and the user should take the appropriate
action. There is no requirement that the three bands come from the same file, so the
user should make sure to properly handle the three FIDs and band positions.

See Also
ENVI_SELECT

ENVI Reference Guide

RGB_GET_BANDS

612

Chapter 2: ENVI Routines

RGB_ITRANS_DOIT
Use this program to perform HSV to RGB and HLS to RGB color transforms using
IDL functions.

Syntax
ENVI_DOIT, RGB_ITRANS_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify a three-element long-integer array of file IDs for the
selected bands. The three elements represent the red, green, and blue bands,
respectively.

HSV
Set this keyword equal to zero to transform from HSV to RGB, or equal to one to
transform from HLS to RGB.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

RGB_ITRANS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

613

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify a three-element long-integer array of band positions.
Elements of POS are paired with elements of the FID array.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_rgb_itrans_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, testhsv.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; inverse HSV transform on all samples
; and first three bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl
t_fid=[fid,fid,fid]
dims = [-1, 0, ns-1, 0, nl-1]

ENVI Reference Guide

RGB_ITRANS_DOIT

614

Chapter 2: ENVI Routines


pos = [0,1,2]
out_name = testimg
;
; Perform the inverse HSV transform
;
envi_doit, rgb_itrans_doit, $
fid=t_fid, pos=pos, dims=dims, $
hsv=1, out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

RGB_ITRANS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

615

RGB_TRANS_DOIT
Use this program to perform RGB to HSV and RGB to HLS color transforms using
IDL functions.

Syntax
ENVI_DOIT, RGB_TRANS_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify a three-element long-integer array of file IDs for the
selected bands. The three elements represent the red, green, and blue bands,
respectively.

HSV
Set this keyword equal to zero to transform from RGB to HSV, or equal to one to
transform from RGB to HLS. The default is zero.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

ENVI Reference Guide

RGB_TRANS_DOIT

616

Chapter 2: ENVI Routines

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify a three-element long-integer array of band positions.
Elements of POS are paired with elements of the FID array.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_rgb_trans_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; RGB HSV transform on all samples
; and first three bands in the file.
;
envi_file_query, fid, ns=ns, nl=nl
t_fid=[fid,fid,fid]
dims = [-1, 0, ns-1, 0, nl-1]

RGB_TRANS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

617

pos = [0,1,2]
out_name = testhsv.img
;
; Perform the HSV transform
;
envi_doit, rgb_trans_doit, $
fid=t_fid, pos=pos, dims=dims, $
hsv=1, out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

RGB_TRANS_DOIT

618

Chapter 2: ENVI Routines

ROC_CURVE_DOIT
Use this program to compute Receiver Operating Characteristic (ROC) Curves. The
ROC Curves compare a series of rule image classification results for different
threshold values with ground truth information. A probability of detection (Pd) versus
probability of false alarm (Pfa) curve and a Pd versus threshold curve are reported for
each selected class (rule band). ENVI can calculate a ROC curve using either a
ground truth image or using ground truth regions of interest (ROIs).

Syntax
ENVI_DOIT, ROC_CURVE_DOIT

Keywords
PLOT_THRESH
Set this keyword to enable the plotting of the probability of detection (PD) versus
threshold plot. The default is to only plot the ROC curves.

CDIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. CDIMS, CFID, and CPOS define the classification rule image used to
compute the ROC curves. CDIMS is a five-element array of long integers with the
following definitions:

CDIMS[0]: Unused for this function, set to 1.

CDIMS[1]: The starting X pixel. (The first pixel is number zero.)

CDIMS[2]: The ending X pixel.

CDIMS[3]: The starting Y pixel. (The first pixel is number zero.)

CDIMS[4]: The ending Y pixel.

CFID
Use this keyword to specify the file ID for the open classification rule image file.
CDIMS, CFID, and CPOS define the classification rule image used to compute the
ROC curves. CFID is the value returned from the keyword R_FID in the
ENVI_OPEN_FILE procedure. CFID is a long integer with a value greater than zero.
An invalid file ID is specified as 1.

ROC_CURVE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

619

CPOS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. CDIMS, CFID, and CPOS define the
classification rule image used to compute the ROC curves. CPOS is an array of long
integers, ranging from zero to the number of bands1.

GDIMS (optional)
Use this optional keyword to specify the spatial dimensions on which to perform the
operation. GDIMS, GFID, and GPOS define the ground truth classification image
used to compute the ROC curves. GDIMS is a five-element array of long integers
with the following definitions:

GDIMS[0]: Unused for this function, set to 1.

GDIMS[1]: The starting X pixel. (The first pixel is number zero.)

GDIMS[2]: The ending X pixel.

GDIMS[3]: The starting Y pixel. (The first pixel is number zero.)

GDIMS[4]: The ending Y pixel.

If the keyword ROI_IDS is not set then GDIMS, GFID, GPOS, and GT_PTR must be set.

GFID (optional)
Use this optional keyword to specify the file ID for the open ground truth
classification image file. GDIMS, GFID, and GPOS define the ground truth
classification image used to compute the ROC curves. GFID is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. GFID is a long
integer with a value greater than zero. An invalid file ID is specified as 1. If the
keyword ROI_IDS is not set then GDIMS, GFID, GPOS, and GT_PTR must be set.

GPOS (optional)
Use this optional keyword to specify an array of band positions, indicating the band
numbers on which to perform the operation. GDIMS, GFID, and GPOS define the
ground truth classification image used to compute the ROC curves. GPOS is an array
of long integers, ranging from zero to the number of bands1. If the keyword
ROI_IDS is not set then GFID, GPOS, and GT_PTR must be set.

GT_PTR (optional)
Use this keyword to specify as a link between the ground truth class and the
corresponding rule image classes. For example, the ground truth class value (the
ENVI Reference Guide

ROC_CURVE_DOIT

620

Chapter 2: ENVI Routines

actual pixel value of the ground truth classification image) GT_PTR[k] corresponds
to the class created from the rule image band CPOS[k]. GT_PTR is a long array with
the same number of elements as CPOS. If the keyword ROI_IDS is not set then GDIMS,
GFID, GPOS, and GT_PTR must be set.

MAX_THRESH
Use this keyword to specify the threshold maximum for classifying the rule images.
The points per curve, as specified by PPC, are evenly distributed between
MIN_THRESH and MAX_THRESH.

METHOD
Set this keyword equal to one of the following values to specify the method for
classifying the rule images.

0 Minimum

1 Maximum

MIN_THRESH
Use this keyword to specify the threshold minimum for classifying the rule images.
The points per curve, as specified by PPC, are evenly distributed between
MIN_THRESH and MAX_THRESH.

PPC
Use this keyword to specify the number of points per ROC curve. The points are
evenly distributed between MIN_THRESH and MAX_THRESH. PPC is a single
long value greater than or equal to 2.

PPW
Use this keyword to specify the maximum number of plot per plot window. PPW is a
single long value greater than zero.

ROI_IDS (optional)
Use this optional keyword to specify the ground truth ROIs. ROI_IDS are the
selected ids of the ground truth ROIs returned from the function
ENVI_GET_ROI_IDS. If ROI_IDS is not set then GDIMS, GFID, and GPOS must
be set.

ROC_CURVE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

621

See Also
CLASS_CONFUSION_DOIT
CLASS_DOIT
CLASS_RULE_DOIT

ENVI Reference Guide

ROC_CURVE_DOIT

622

Chapter 2: ENVI Routines

ROI_THRESH_DOIT
Use this program to create an ROI that contains all pixels with values above, below,
or between threshold pixel values.

Syntax
ENVI_DOIT, ROI_THRESH_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

MAX_THRESH
Use this keyword to specify the maximum threshold. Values below MAX_THRESH
are included in the ROI.

MIN_THRESH
Use this keyword to specify the minimum threshold. Values above MIN_THRESH
are included in the ROI.

ROI_THRESH_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

623

NO_QUERY
Set this keyword to suppress bringing up any informational or interactive dialogs
during the threshold process.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

ROI_ID
Set this keyword to named variable containing ID of the resulting ROI.

ROI_NAME
Use this keyword to specify an output roi name for the generated region of interest.

ROI_COLOR
Use this keyword to specify the output ROI color. ROI_COLOR is a LONG variable
representing the index into the ENVI graphic colors. By default ENVI has 17 graphic
colors and the index values would range from 0 to 16.

Example
pro example_roi_thresh_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS keywords to process all

ENVI Reference Guide

ROI_THRESH_DOIT

624

Chapter 2: ENVI Routines


; spatial pixels and use the POS
; keyword to select the first band
; to use for the ROI.
;
envi_file_query, fid, ns=ns, nl=nl
dims = [-1, 0, ns-1, 0, nl-1]
pos = [0]
roi_name = test ROI
out_name = test.roi
;
; Perform the ROI threshold
;
envi_doit, roi_thresh_doit, $
fid=fid, pos=pos, dims=dims, $
max_thresh=255, min_thresh=30, $
/no_query, roi_color=5, $
roi_name=roi_name, roi_id=roi_id
;
; Save the ROI to a file
;
envi_save_rois, out_name, roi_id
;
; Exit ENVI
;
envi_batch_exit
end

ROI_THRESH_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

625

ROTATE_DOIT
Use this program to rotate images using standard IDL rotations and transpositions.

Syntax
ENVI_DOIT, ROTATE_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

ENVI Reference Guide

ROTATE_DOIT

626

Chapter 2: ENVI Routines

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

ROT_TYPE
Use this keyword to specify the rotation type by setting it equal to one of the
following values:

0 0 degrees

1 90 degrees

2 180 degrees

3 270 degrees

TRANSPOSE
Set this keyword to cause the image to be transposed.

Notes
Rotations and transpose are performed as per the IDL conventions.

Example
pro example_rotate_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;

ROTATE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

627

envi_open_file, can_tmr.img, r_fid=fid


if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS and POS to keywords
; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Rotate the image by 90 degrees.
;
envi_doit, rotate_doit, $
fid=fid, pos=pos, dims=dims, $
rot_type=1, out_name=out_name, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

ROTATE_DOIT

628

Chapter 2: ENVI Routines

RTV_DOIT
Use this program to perform a raster to vector conversion for a classification image or
for a contour level on a grayscale image.

Syntax
ENVI_DOIT, RTV_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to an array of ones and zeros indicating the storage location for each
of the output vectors. IN_MEMORY is a long array of ones and zero with the same
number of elements as VALUES and OUT_NAME.

L_NAME
Use this keyword to specify a string array of vector level names. L_NAME has the
same number of elements as the keyword VALUES.

RTV_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

629

OUT_NAME
Use this keyword to specify a string array of output vector file names. The
OUT_NAME array must have a valid output filename for each of the zero values in
the array IN_MEMORY. OUT_NAME has the same number of elements as the
keywords VALUES and IN_MEMORY.

POS
Use this keyword to specify the band position on which to perform the operation.
POS is a single element long integer array, ranging from zero to the number of
bands-1.

VALUES
Use this keyword to specify an array of classification class values to contour or
grayscale contour levels. A vector file will be generated for each element in the
VALUES array.

Example
pro example_rtv_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the data and class files
;
envi_open_file, bhtm_sam.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keyword to convert
; all spatial data for
; the first three class (the
; Unclassified class is the
; zero class) to vectors. Each of
; the classes will be output to a

ENVI Reference Guide

RTV_DOIT

630

Chapter 2: ENVI Routines


; separate vector file.
;
envi_file_query, fid, ns=ns, nl=nl, $
class_names=class_names
pos = [0]
values = [1, 2, 3]
dims = [-1, 0, ns-1, 0, nl-1]
l_name = class_names[values]
out_names = testimg_ + $
strcompress(string(values),/remove_all) + .evf
in_memory = lonarr(n_elements(values))
;
; Call the raster to vector
; processing routine.
;
envi_toggle_catch
envi_doit, rtv_doit, $
fid=fid, pos=pos, dims=dims, $
values=values, l_name=l_name, $
in_memory=in_memory, $
out_names=out_names
;
; Exit ENVI
;
envi_batch_exit
end

RTV_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

631

SAT_STRETCH_DOIT
Use this program to perform a Saturation Stretch on the data.

Syntax
ENVI_DOIT, SAT_STRETCH_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

ENVI Reference Guide

SAT_STRETCH_DOIT

632

Chapter 2: ENVI Routines

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_sat_stretch_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keywords. We will perform the
; saturation stretch on the first
; three bands in the file and all
; spatial pixels.
;
envi_file_query, fid, ns=ns, nl=nl
t_fid = [fid,fid,fid]
dims = [-1, 0, ns-1, 0, nl-1]
pos = [0,1,2]
out_name = testimg
;
; Perform the decorrelation stretch
;
envi_doit, sat_stretch_doit, $
fid=t_fid, pos=pos, dims=dims, $

SAT_STRETCH_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

633

out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

SAT_STRETCH_DOIT

634

Chapter 2: ENVI Routines

SHARPEN_DOIT
Use this program to perform HSV (Hue, Saturation, Value) and Color Normalized
sharpening on an image.

Syntax
ENVI_DOIT, SHARPEN_DOIT

Keywords
F_DIMS
Use this keyword to specify the spatial dimensions of the high resolution image.
DIMS is a five-element array of long integers with the following definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

F_FID
Use this keyword to specify the high resolution data file ID for the open file. This is
the value returned from the keyword R_FID in the ENVI_OPEN_FILE procedure.
FID is a long integer with a value greater than zero. An invalid file ID is specified as
-1.

F_POS
Use this keyword to specify the band position of the high resolution sharpening band.
F_POS is a single long value greater than or equal to zero.

FID
Use this keyword to specify the file IDs for the three bands to sharpen. This is the
value returned from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is
a long integer with a value greater than zero. An invalid file ID is specified as -1.

SHARPEN_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

635

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

INTERP
Use this keyword to specify an integer value corresponding to the interpolation type.
Choose one of the following.

0 Nearest Neighbor

1 Bilinear

2 Cubic Convolution

METHOD
Use this keyword to specify the sharpening method. METHOD is a long value set to
one of the following.

0 HSV sharpening

1 Color Normalized sharpening

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify the three band positions to perform the operations on.
Each element of POS corresponds to the appropriate file in the FID array. POS is a
long array of three with each element ranging from 0 to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

ENVI Reference Guide

SHARPEN_DOIT

636

Chapter 2: ENVI Routines

Example
pro example_sharpen_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file high resolution file
;
envi_open_file, bldr_sp.img, r_fid=f_fid
if (f_fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the keyword DIMS and POS to
; process all spatial and all spectral
; data.
;
envi_file_query, f_fid, ns=f_ns, nl=f_nl
; Set the keywords
f_dims = [-1l, 0, f_ns-1, 0, f_nl-1]
f_pos = [0]
;
; Open the file for the RGB bands
;
envi_open_file, bldrtm_m.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
envi_file_query, fid, bnames=bnames
pos = [2,1,0]
rgb_fid = [fid,fid,fid]
out_name = testimg
out_bname = [Red,Green,Blue]
;
; Call the sharpening processing
; routine.
;
envi_doit, sharpen_doit, $
fid=rgb_fid, pos=pos, f_fid=f_fid, $

SHARPEN_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

637

f_dims=f_dims, f_pos=f_pos, $
out_name=out_name, method=1, $
interp=0, out_bname=out_bname
;
; Exit ENVI
;
envi_batch_exit
end

See Also
ENVI_PC_SHARPEN_DOIT
ENVI_GS_SHARPEN_DOIT

ENVI Reference Guide

SHARPEN_DOIT

638

Chapter 2: ENVI Routines

SIRC_HEADER_DOIT
Use this function to read the SIRC header information used by other SIRCroutines.

Syntax
Result = SIRC_HEADER_DOIT([, AZ_KM=variable] [, BAND=variable]
[, CANCEL=variable] [, FILENAME=string] [, NL=variable] [, NS=variable]
[, OFFSET=variable] [, RANGE_KM=variable] [, SLH=variable]
[, TYPE=variable])

Return Value
Returns a 1 if the specified file is a SIRC file otherwise 0 is returned. The desired
SIRC information is returned using optional keywords.

Arguments
None

Keywords
AZ_KM (optional)
Use this optional keyword to specify a named variable that will contain the azimuth
or Y image size in kilometers.

BAND (optional)
Use this optional keyword to specify a named variable that will contain the band
number for the file specified by FNAME. BAND is set to 0 for C-Band and 1 for
L-Band.

CANCEL (optional)
Use this optional keyword to specify a named variable that will be set to 0 if the user
cancels the read request.

FILENAME
Use this keyword to specify the filename of the AIRSAR file.

SIRC_HEADER_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

639

NL (optional)
Use this optional keyword to specify a named variable that will contain the number of
lines in the SIRC image.

NS (optional)
Use this optional keyword to specify a named variable that will contain the number of
samples per line in SIRC image.

OFFSET (optional)
Use this optional keyword to specify a named variable that will contain the offset for
the file specified by FNAME.

RANGE_KM (optional)
Use this optional keyword to specify a named variable that will contain the range or
X image size in kilometers.

SLH (optional)
Use this optional keyword to specify a named variable that will contain a flag
indicated whether the file needs to skip the line header. A one indicates that the line
header must be skipped when processing.

TYPE (optional)
Use this optional keyword to specify an named variable that will contain the SIRC
data product type for the file specified by FILENAME.
0: MLC Quad Pole.

5: SLC Dual Pole HH VV

1: MLC Dual Pole HH VV

6: SLC Dual Pole HH HV

2: MLC Dual Pole HH HV

7: SLC Dual Pole VH VV

3: MLC Dual Pole VH VV

8: SLC Single Pole HH

4: SLC Quad Pole.

9: SLC Single Pole HH

ENVI Reference Guide

SIRC_HEADER_DOIT

640

Chapter 2: ENVI Routines

Example
pro example_sirc_header_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the keywords
;
filename = ndv_l.cdp
;
; Call the "doit"
;
envi_doit, sirc_header_doit, $
filename=filename, ns=ns, nl=nl, $
type=type, cancel=cancel, $
offset=offset, band=band, az_km=az_km, $
range_km=range_km, slh=slh
;
; Print the result
;
print, ns = , ns
print, nl = , nl
print, offset = , offset
print, type = , type
print, slh = , slh
print, band = , band
print, az_km = , az_km
print, range_km = , range_km
;
; Exit ENVI
;
envi_batch_exit
end

SIRC_HEADER_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

641

SIRC_MULTILOOK_DOIT
Use this program to Multilook SIRC compressed data products.

Syntax
ENVI_DOIT, SIRC_MULTILOOK_DOIT

Keywords
AZ_M
Use this keyword to specify the azimuth or Y image size in meters.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FNAME
Use this keyword to specify a string array of compressed data products file names for
C and/or L wavelengths respectively. If a file is not used then set the
array element to .

F_NS
Use this keyword to specify the number of samples per line in SIRC image.

F_NL
Use this keyword to specify the number of lines in the SIRC image.

ENVI Reference Guide

SIRC_MULTILOOK_DOIT

642

Chapter 2: ENVI Routines

LOOK
Set this keyword to specify the look factor to apply to the X and Y directions, range
and azimuth respectively. LOOK is a float array of length 2.

OFFSET
Use this keyword to specify an long array of header offsets for each of the files
specified by FNAME.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

RANGE_M
Use this keyword to specify the range or X image size in meters.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

SLH
Use this keyword to specify a long array indicating which files need to strip the line
header. A zero indicates that line header is not present and a one indicates that the 12
byte SIRC line header must be stripped. SLH must have the same number of elements
as FNAME.

TYPE
Use this keyword to specify an array of SIRC data product type for each of the files
specified by FNAME.
Value

Definition

MLC Quad Pole.

MLC Dual Pole HH VV

MLC Dual Pole HH HV

Table 35-7: TYPE Keyword Values

SIRC_MULTILOOK_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

643

Value

Definition

MLC Dual Pole VH VV

SLC Quad Pole.

SLC Dual Pole HH VV

SLC Dual Pole HH HV

7:

SLC Dual Pole VH VV

SLC Single Pole HH

9:

SLC Single Pole HH

Table 35-7: TYPE Keyword Values (Continued)

XSTART
Use this keyword to specify the X offset of the input file.

YSTART
Use this keyword to specify the Y offset of the input file.

Example
pro example_sirc_multilook_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the keywords
;
fname = ndv_l.cdp
;
; First get necessary information
; about the SIR data file.
;
envi_doit, sirc_header_doit, $
filename=fname, ns=ns, nl=nl, $

ENVI Reference Guide

SIRC_MULTILOOK_DOIT

644

Chapter 2: ENVI Routines


type=type, cancel=cancel, $
offset=offset, band=band, az_km=az_km, $
range_km=range_km, slh=slh
;
;
; Set the necessary keywords. Use a
; multilook of 10 in both the samples
; and lines. This will make the output
; image 10 times smaller in both
;directions.
;
dims = [-1, 0, ns-1, 0, nl-1]
az_m = (az_km * 1000.) / 10.
range_m = (range_km * 1000.) / 10.
look = [10,10]
out_name = testimg
;
; Perform the multilook processing
;
envi_doit, sirc_multilook_doit, $
fname=fname, f_ns=ns, f_nl=nl, $
dims=dims, az_m=az_m, range_m=range_m, $
offset=offset, look=look, $
slh=slh, type=type, xstart=0, $
ystart=0, out_name=out_name
;
; Exit ENVI
;
envi_batch_exit
end

SIRC_MULTILOOK_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

645

SIRC_PED_HEIGHT_DOIT
Use this program to calculate pedestal height images from a SIRC compressed data
products file.

Syntax
ENVI_DOIT, SIRC_PED_HEIGHT_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FNAME
Use this keyword to specify a string array of compressed data products file names for
C and/or L wavelengths respectively. If a file is not used then set the
array element to .

FNS
Use this keyword to specify the number of samples per line in SIRC image.

FNL
Use this keyword to specify the number of lines in the SIRC image.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

ENVI Reference Guide

SIRC_PED_HEIGHT_DOIT

646

Chapter 2: ENVI Routines

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OFFSET
Use this keyword to specify a long array of header offsets for each of the files
specified by FNAME.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

SLH
Use this keyword to specify a long array indicating which files need to strip the line
header. A zero indicates that line header is not present and a one indicates that the 12
byte SIRC line header must be stripped. SLH must have the same number of elements
as FNAME.

TYPE
Use this keyword to specify an array of SIRC data product type for each of the files
specified by FNAME.
Value

Definition

MLC Quad Pole.

MLC Dual Pole HH VV

MLC Dual Pole HH HV

MLC Dual Pole VH VV

SLC Quad Pole.

SLC Dual Pole HH VV

Table 35-8: TYPE Keyword Values

SIRC_PED_HEIGHT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

647

Value

Definition

SLC Dual Pole HH HV

SLC Dual Pole VH VV

SLC Single Pole HH

SLC Single Pole HH

Table 35-8: TYPE Keyword Values (Continued)

Example
pro example_sirc_ped_height_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the keywords
;
fname = ndv_l.cdp
;
; First get necessary information
; about the SIR data file.
;
envi_doit, sirc_header_doit, $
filename=fname, ns=ns, nl=nl, $
type=type, cancel=cancel, $
offset=offset, band=band, az_km=az_km, $
range_km=range_km, slh=slh
;
;
; Set the DIMS keyword to calculate the
; pedestal height image for all spatial
; pixels.
;
dims = [-1, 0, ns-1, 0, nl-1]
out_name = testimg
;
; Perform the processing
;

ENVI Reference Guide

SIRC_PED_HEIGHT_DOIT

648

Chapter 2: ENVI Routines


envi_doit, sirc_ped_height_doit, $
fname=fname, fns=ns, fnl=nl, $
dims=dims, offset=offset, slh=slh, $
type=type, out_name=out_name, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

SIRC_PED_HEIGHT_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

649

SIRC_PHASE_IMAGE_DOIT
Use this program to calculate phase images from a SIRC compressed data products
file.

Syntax
ENVI_DOIT, SIRC_PHASE_IMAGE_DOIT

Keywords
DEGREE (optional)
Set this optional keyword to output the phase images in degrees. the default is
radians.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FNAME
Use this keyword to specify a string array of compressed data products file names for
C and/or L wavelengths. A phase image will be calculated for each file in FNAME.

FNS
Use this keyword to specify the number of samples per line in SIRC image.

FNL
Use this keyword to specify the number of lines in the SIRC image.

ENVI Reference Guide

SIRC_PHASE_IMAGE_DOIT

650

Chapter 2: ENVI Routines

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OFFSET
Use this keyword to specify a long array of header offsets for each of the files
specified by FNAME.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

SLH
Use this keyword to specify a long array indicating which files need to strip the line
header. A zero indicates that line header is not present and a one indicates that the 12
byte SIRC line header must be stripped. SLH must have the same number of elements
as FNAME.

TYPE
Use this keyword to specify an array of SIRC data product type for each of the files
specified by FNAME.
Value

Definition

MLC Quad Pole.

MLC Dual Pole HH VV

MLC Dual Pole HH HV


Table 35-9: TYPE Keyword Values

SIRC_PHASE_IMAGE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

651

Value

Definition

MLC Dual Pole VH VV

SLC Quad Pole.

SLC Dual Pole HH VV

SLC Dual Pole HH HV

SLC Dual Pole VH VV

SLC Single Pole HH

SLC Single Pole HH

Table 35-9: TYPE Keyword Values (Continued)

Example
pro example_sirc_phase_image_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the keywords
;
fname = ndv_l.cdp
;
; First get necessary information
; about the SIR data file.
;
envi_doit, sirc_header_doit, $
filename=fname, ns=ns, nl=nl, $
type=type, cancel=cancel, $
offset=offset, band=band, az_km=az_km, $
range_km=range_km, slh=slh
;
;
; Set the DIMS keyword to calculate the
; phase image for all spatial pixels.
;

ENVI Reference Guide

SIRC_PHASE_IMAGE_DOIT

652

Chapter 2: ENVI Routines


dims = [-1, 0, ns-1, 0, nl-1]
out_name = testimg
;
; Perform the processing
;
envi_doit, sirc_phase_image_doit, $
fname=fname, fns=ns, fnl=nl, $
dims=dims, offset=offset, slh=slh, $
type=type, out_name=out_name, $
/degree, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

SIRC_PHASE_IMAGE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

653

SIRC_POLSIG_DOIT
Use this program to calculate polarization signatures from a SIRC compressed data
products file.

Syntax
ENVI_DOIT, SIRC_POLSIG_DOIT

Keywords
BANDS
Use this keyword to specify a two-element array of ones and zeros indicating whether
the C and wavelengths were used. A value of one indicates the wavelength was used.
BANDS must be two elements long regardless of the size of FNAME.

BFNAME
Use this keyword to specify a two-element string array where each element specifies
C and L annotations for the header description. BFNAME must be two elements long
regardless of the size of FNAME.

FNAME
Use this keyword to specify a string array of compressed data products file names for
C and/or L wavelengths respectively. If a file is not used then set the array element to
.

FNS
Use this keyword to specify the number of samples per line in SIRC image.

FNL
Use this keyword to specify the number of lines in the SIRC image.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

ENVI Reference Guide

SIRC_POLSIG_DOIT

654

Chapter 2: ENVI Routines

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OFFSET
Use this keyword to specify a long array of header offsets for each of the files
specified by FNAME.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

ROI_ID
Use this keyword to specify an array of ROI IDs returned from a call to
ENVI_GET_ROI_IDS. Each ID in the array will use the corresponding ROI to
calculate both a co-polarization and cross-polarization image.

SLH
Use this keyword to specify a long array indicating which files need to strip the line
header. A zero indicates that line header is not present and a one indicates that the 12
byte SIRC line header must be stripped. SLH must have the same number of elements
as FNAME.

TYPE
Use this keyword to specify an array of SIRC data product type for each of the files
specified by FNAME.
0: MLC Quad Pole.

5: SLC Dual Pole HH VV

1: MLC Dual Pole HH VV

6: SLC Dual Pole HH HV

2: MLC Dual Pole HH HV

7: SLC Dual Pole VH VV

3: MLC Dual Pole VH VV

8: SLC Single Pole HH

4: SLC Quad Pole.

9: SLC Single Pole HH

SIRC_POLSIG_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

655

Example
forward_function envi_get_roi_ids
pro example_sirc_polsig_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the keywords
;
fname = ndv_l.cdp
;
; First get necessary information
; about the SIR data file.
;
envi_doit, sirc_header_doit, $
filename=fname, ns=ns, nl=nl, $
type=type, cancel=cancel, $
offset=offset, band=band, az_km=az_km, $
range_km=range_km, slh=slh
;
; Restore the polarization signature
; ROI and get the ROI ids.
;
envi_restore_rois, pol_sig.roi
roi_ids = envi_get_roi_ids(ns=ns, nl=nl)
;
; Set the DIMS keyword to calculate the
; phase image for all spatial pixels.
;
dims = [-1, 0, ns-1, 0, nl-1]
bands = [0,1,0]
out_name = testimg
bfname = [,fname,]
;
; Perform the processing
;
envi_doit, sirc_polsig_doit, $
fname=fname, fns=ns, fnl=nl, $
offset=offset, slh=slh, type=type, $
roi_ids=roi_ids, bfname=bfname, $

ENVI Reference Guide

SIRC_POLSIG_DOIT

656

Chapter 2: ENVI Routines


bands=bands, out_name=out_name, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

SIRC_POLSIG_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

657

SIRC_SYNTH_DOIT
Use this program to synthesize images from SIR-C compressed data products files.

Syntax
ENVI_DOIT, SIRC_SYNTH_DOIT

Keywords
COMBO
Use this keyword to specify a 5 x n array of ellipticity and orientation angles for each
image synthesized. The format for the array is:

(0,i) - transmit ellipticity for ith image.

(1,i) - transmit orientation for ith image.

(2,i) - receive ellipticity for ith image.

(3,i) - receive orientation for ith image.

(4,i) - stokes band number 0-C, 1-L.

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FNAME
Use this keyword to specify a string array of compressed data products file names for
C and/or L wavelengths respectively. If a file is not used then set the
array element to .

ENVI Reference Guide

SIRC_SYNTH_DOIT

658

Chapter 2: ENVI Routines

FNS
Use this keyword to specify the number of samples per line in SIRC image.

FNL
Use this keyword to specify the number of lines in the SIRC image.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

MAX_VAL (optional)
Use this keyword to set an optional maximum value for output data.

MIN_VAL (optional)
Use this keyword to set an optional minimum value for output data.

OFFSET
Use this keyword to specify an long array of header offsets for each of the files
specified by FNAME.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OUT_DT
Use this keyword to specify the output data type, either 1 for byte or 4 for floating
point. All other output data types are invalid.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

SIGMA_ZERO
Set this keyword to specify that the output values be converted to sigma zero,
10*log10(data).

SIRC_SYNTH_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

659

SLH
Use this keyword to specify a long array indicating which files need to strip the line
header. A zero indicates that line header is not present and a one indicates that the 12
byte SIRC line header must be stripped. SLH must have the same number of elements
as FNAME.

STDMULT
Set this keyword to specify the standard deviation multiplier for byte output data
types. Plus and minus the STDMULT determines the output minimum and
maximum.

TOTAL_POWER
Use this keyword to specify a three element array of ones and zeros indicating
whether the total power should be computed for the C and/or L wavelengths
respectively. A value of one causes the synthesis of the total power image.

TYPE
Use this keyword to specify an array of SIRC data product type for each of the files
specified by FNAME.
Value

Definition

MLC Quad Pole.

MLC Dual Pole HH VV

MLC Dual Pole HH HV

MLC Dual Pole VH VV

SLC Quad Pole.

SLC Dual Pole HH VV

SLC Dual Pole HH HV

SLC Dual Pole VH VV

SLC Single Pole HH

SLC Single Pole HH


Table 35-10: TYPE Keyword Values

ENVI Reference Guide

SIRC_SYNTH_DOIT

660

Chapter 2: ENVI Routines

XFAC
Use this keyword to specify an X subsampling factor used to compute image data
statistics prior to the conversion to byte. The keyword is only used when the output
data type is byte.

YFAC
Use this keyword to specify an Y subsampling factor used to compute image data
statistics prior to the conversion to byte. The keyword is only used when the output
data type is byte.

Example
pro example_sirc_synth_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the keywords
;
fname = ndv_l.cdp
;
; First get necessary information
; about the SIR data file.
;
envi_doit, sirc_header_doit, $
filename=fname, ns=ns, nl=nl, $
type=type, cancel=cancel, $
offset=offset, band=band, az_km=az_km, $
range_km=range_km, slh=slh
;
;
; Set the DIMS keyword to synthesize all
; spatial pixels. Since we are only using
; the L band we need to set null values
; for the other wavelengths.
;
dims = [-1, 0, ns-1, 0, nl-1]
combo = [[0.,0.,0.,0.,1]]
total_power = [0,1,0]

SIRC_SYNTH_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

661

slh = [0, slh]


offset = [0, offset]
fname = [, fname]
out_name = testimg
;
; Perform the processing
;
envi_doit, sirc_synth_doit, $
fname=fname, fns=ns, fnl=nl, $
dims=dims, offset=offset, slh=slh, $
type=type, combo=combo, out_dt=4, $
total_power=total_power, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

SIRC_SYNTH_DOIT

662

Chapter 2: ENVI Routines

SLICE_DOIT
Use this program to extract a spectral slice and store the result as an image.

Syntax
ENVI_DOIT, SLICE_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-elements array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.) This element
specifies the sample for the vertical spectral slice.

DIMS[2]: The ending X pixel. (Unused for this function.)

DIMS[3]: The starting Y pixel. (The first pixel is number zero.) This element
specifies the line for the horizontal spectral slice.

DIMS[4]: The ending Y pixel. (Unused for this function.)

FID
Use this keyword to specify the file ID for the open file. This is the value returned by
the R_FID keyword to the ENVI_OPEN_FILE procedure. FID is a long integer with
a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output is stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

SLICE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

663

OUT_NAME
Use this keyword to specify an output filename for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable in which the file ID for the processed
data will be returned. This file ID can be used to access the processed data.

VERTICAL
Set this keyword to indicate that a vertical slice is to be extracted. The extracted
column is specified by dims(1). A vertical slice image has the following size: the
number of samples is equal to the number of elements in POS and the number of lines
is equal to the number of lines in the input image.

HORIZONTAL
Set this keyword to indicate that a horizontal slice is to be extracted. The extracted
line is specified by dims(3). A horizontal slice image has the following size: the
number of samples is equal to the number samples in the input image and the number
of lines is equal to the number of elements in the POS array.

ENVI Reference Guide

SLICE_DOIT

664

Chapter 2: ENVI Routines

SLT2GND_DOIT
Use this program to convert from slant to ground range.

Syntax
ENVI_DOIT, SLT2GND_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

HEIGHT
Use this keyword to specify the instrument height in meters.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

LEFT_LOOK
Set this keyword to specify that the instrument was left looking in the range direction.

SLT2GND_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

665

NR_RANGE
Use this keyword to specify the instrument near range in meters.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

PS_OUTPUT
Use this keyword to specify the pixel size of the ground rang data. PS_OUTPUT is
expressed in meters.

PS_SLANT_RANGE
Use this keyword to specify the pixel size in slant range. PS_SLANT_RANGE is
expressed in meters.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

RESAMPLING
Use this keyword to specify the pixel resampling method. Set RESAMPLING to one
of the following.

0 Nearest Neighbor

1 Bilinear

2 Cubic Convolution

ENVI Reference Guide

SLT2GND_DOIT

666

Chapter 2: ENVI Routines

RANGE_DIR
Use this keyword to specify the range direction. If unset then the range direction is
assumed to be in the samples direction. If set then the range direction is in the line
direction.

Example
pro example_slt2gnd_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bonnrsat.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS and POS to keywords
; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Perform the slant to ground
; correction.
;
envi_doit, slt2gnd_doit, $
fid=fid, pos=pos, dims=dims, $
height=27460., nr_dist=28360, $
ps_slant_range=8., ps_output=10.0, $
range_dir=1, resampling=2, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI

SLT2GND_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

667

;
envi_batch_exit
end

ENVI Reference Guide

SLT2GND_DOIT

668

Chapter 2: ENVI Routines

SPECTRAL_FEATURE_DOIT
Use this program to perform spectral feature fitting.

Syntax
ENVI_DOIT, SPECTRAL_FEATURE_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

ENDMEM
Use this keyword to specify the endmembers array. ENDMEM is a 2-dimensional
floating point array (nb, # end members).

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

SPECTRAL_FEATURE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

669

M_FID
Use this keyword to specify the file ID for the mask file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

M_POS
Use this keyword to specify the band position of the mask band. M_POS is a single
long value greater than or equal to zero.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_MODE
Use this keyword to specify the output mode. OUT_MODE should be set to one of
the following.

0 output separate files for Scale and RMS

1 output Scale/RMS to a single file.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify a one-dimension array of band positions indicating the
band numbers to perform the operations on. POS is a long array ranging from 0 to the
number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

REMOVE_CONT
Set this keyword to specify that the Continuum Removal should be run prior to
Spectral Feature FittingTM.

ENVI Reference Guide

SPECTRAL_FEATURE_DOIT

670

Chapter 2: ENVI Routines

Example
pro example_spectral_feature_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, mof94av.bil, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS and POS to keywords
; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
envi_file_query, fid, ns=ns, nl=nl, $
nb=nb
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Read in the endmember text file.
; The first column are the
; wavelengths and the next 19
; columns are the endmembers. We will
; use the 19 endmembers for spectral
; feature fitting. The endmember data
; must also be transposed in order to
; send in a (nb, # endmember) array.
;
envi_read_cols, m94_em.asc, $
endmem, skip=em_names, /read_skip
endmem = transpose(endmem[1:*,*])
out_bname = Fit ( + em_names[2:*] + )
;
; Call the spectral feature fitting
; routine. Output the Scale/RMS image

SPECTRAL_FEATURE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

671

; for each endmember.


;
envi_doit,spectral_feature_doit, $
fid=fid, pos=pos, dims=dims, $
endmem=endmem, /remove_cont, $
out_mode=1, out_bname=out_bname, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

SPECTRAL_FEATURE_DOIT

672

Chapter 2: ENVI Routines

STRETCH_DOIT
Use this program to perform contrast stretching of image data.

Syntax
ENVI_DOIT, STRETCH_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

I_MAX
Use this keyword to specify either the maximum percent stretch value or the
maximum value, depending on the value of the RANGE_BY keyword.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

STRETCH_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

673

I_MIN
Use this keyword to specify either the minimum percent stretch value or the
minimum value, depending on the value of the RANGE_BY keyword.

METHOD
Use this keyword to specify which type of stretch to perform:

1 linear.

2 equalize.

3 gaussian.

4 square root.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_DT
Set this keyword to indicate the IDL data type of the output data using the following
IDL convention:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

OUT_MAX
Use this keyword to specify the maximum output value.

ENVI Reference Guide

STRETCH_DOIT

674

Chapter 2: ENVI Routines

OUT_MIN
Use this keyword to specify the minimum output value.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

RANGE_BY
Use this keyword to indicate the type of ranging. If RANGE_BY is set to 1, the
keywords I_MIN and I_MAX contain absolute minimum and maximum values. If
RANGE_BY is set to zero, I_MIN and I_MAX contain percent stretch values.

STDV
Use this keyword to specify the standard deviation for the gaussian stretch.

Example
pro example_stretch_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid

STRETCH_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

675

if (fid eq -1) then begin


envi_batch_exit
return
endif
;
; Set the DIMS and POS keywords
; to process all spatial and all
; spectral data.
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Call the stretch processing routine.
; We will perform a 2% stretch on the
; data and output a byte image with
; a zero to 255 range.
;
envi_doit, stretch_doit, $
fid=fid, pos=pos, dims=dims, $
method=1, out_name=out_name, $
i_min=2.0, i_max=98.0, range_by=0, $
out_min=0, out_max=255, out_dt=1, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

STRETCH_DOIT

676

Chapter 2: ENVI Routines

TASCAP_DOIT
Use this program to create Tasseled Cap vegetation and soil indices.

Syntax
ENVI_DOIT, TASCAP_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to 1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as 1.

FILE_TYPE
Set this keyword to indicate TM or MSS data. Set FILE_TYPE to one of the
following:
Value

Definition

TM data

MSS data

Table 36-11: FILE_TYPE Keyword Values

TASCAP_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

677

Value
2

Definition
Landsat 7 ETM

Table 36-11: FILE_TYPE Keyword Values (Continued)

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands1. POS must define 6 bands for TM data and 4 bands for
MSS data.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_tascap_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit

ENVI Reference Guide

TASCAP_DOIT

678

Chapter 2: ENVI Routines


return
endif
;
; Set the DIMS and POS to keywords
; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Perform the Tasseled Cap vegetation
; and soil indices for the TM data.
;
envi_doit, tascap_doit, $
fid=fid, pos=pos, dims=dims, $
file_type=0, out_name=out_name, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

TASCAP_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

679

TEXTURE_COOCCUR_DOIT
Use this program to calculate texture co-occurrence measures for an image.

Syntax
ENVI_DOIT, TEXTURE_COOCCUR_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

DIRECTION
Use this keyword to specify the direction and distance between the co-occurrence
kernels. DIRECTION is a two element long array of the X and Y distances and
directions. For example, if DIRECTION=[2,-1] then displacement would be two
pixels to the right and one line up.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

ENVI Reference Guide

TEXTURE_COOCCUR_DOIT

680

Chapter 2: ENVI Routines

KX
Use this keyword to specify the X kernel size in pixels for calculating the texture
measures. Each texture measure is calculated from the localized kernel specified by
KX and KY.

KY
Use this keyword to specify the Y kernel size in pixels for calculating the texture
measures. Each texture measure is calculated from the localized kernel specified by
KX and KY.

METHOD
Use this keyword to specify an array of ones zero indicating which texture measure to
compute. METHOD is a eight element array of integers with the following
definitions:

METHOD(0) - Compute the co-occurrence mean.

METHOD(1) - Compute the co-occurrence variance.

METHOD(2) - Compute the co-occurrence homogeneity.

METHOD(3) - Compute the co-occurrence contrast.

METHOD(4) - Compute the co-occurrence dissimilarity.

METHOD(5) - Compute the co-occurrence entropy.

METHOD(6) - Compute the co-occurrence second moment.

METHOD(7) - Compute the co-occurrence correlation.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

TEXTURE_COOCCUR_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

681

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
pro example_texture_cooccur_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS and POS to keywords
; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
method = lonarr(8) + 1
direction = [2,2]
out_name = testimg
;
; Perform the texture cooccurence
; calculation.
;
envi_doit, texture_cooccur_doit, $
fid=fid, pos=pos, dims=dims, $
method=method, kx=5, ky=5, $
direction=direction, $
out_name=out_name, r_fid=r_fid
;
; Exit ENVI

ENVI Reference Guide

TEXTURE_COOCCUR_DOIT

682

Chapter 2: ENVI Routines


;
envi_batch_exit
end

TEXTURE_COOCCUR_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

683

TEXTURE_STATS_DOIT
Use this program to calculate texture measure for an image.

Syntax
ENVI_DOIT, TEXTURE_STATS_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

KX
Use this keyword to specify the X kernel size in pixels for calculating the texture
measures. Each texture measure is calculated from the localized kernel specified by
KX and KY.

ENVI Reference Guide

TEXTURE_STATS_DOIT

684

Chapter 2: ENVI Routines

KY
Use this keyword to specify the Y kernel size in pixels for calculating the texture
measures. Each texture measure is calculated from the localized kernel specified by
KX and KY.

METHOD
Use this keyword to specify an array of ones and zeros indicating which texture
measure to compute. METHOD is a five element array of integers with the following
definitions:

METHOD[0] - Compute the kernel data range.

METHOD[1] - Compute the kernel mean.

METHOD[2] - Compute the kernel variance.

METHOD[3] - Compute the kernel entropy.

METHOD[4] - Compute the kernel skewness

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

TEXTURE_STATS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

685

Example
pro example_texture_stats_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhtmref.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS keyword to
; process all spatial and use
; the POS keyword to calculate
; the texture measures only for
; the first band (band zero).
; Use a 5x5 kernel to calculate
; all texture measures (data range,
; mean, variance, entropy, skewness).
; The results will be save to disk.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1l, 0, ns-1, 0, nl-1]
pos = [0]
out_name = testimg
out_bname = [Data Range, Mean, $
Variance, Entropy, Skewness]
method = [1,1,1,1,1]
;
; Call the texture processing
; routine.
;
envi_doit, texture_stats_doit, $
fid=fid, pos=pos, dims=dims, $
kx=5, ky=5, method=method, $
out_name=out_name, r_fid=r_fid, $
out_bname=out_bname
;

ENVI Reference Guide

TEXTURE_STATS_DOIT

686

Chapter 2: ENVI Routines


; Exit ENVI
;
envi_batch_exit
end

TEXTURE_STATS_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

687

TIMS_CAL_DOIT
Use this program to calibrate TIMS data to radiance. This routine uses the calibration
information at the start of each line to calibrate the data.

Syntax
ENVI_DOIT, TIMS_CAL_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

ENVI Reference Guide

TIMS_CAL_DOIT

688

Chapter 2: ENVI Routines

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

REF_SMOOTH
Use this keyword to specify the width of the reference data moving average window.
REF_SMOOTH lines are averaged together and used for the calibration.
REF_SMOOTH is a single long value.

Example
pro example_tims_cal_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, tims_data.raw, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS and POS to keywords
; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg

TIMS_CAL_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

689

;
; Perform the TIMS Calibration.
;
envi_doit, tims_cal_doit, $
fid=fid, pos=pos, dims=dims, $
ref_smooth=20, out_name=out_name, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

See Also
EMITTANCE_CALC_DOIT

ENVI Reference Guide

TIMS_CAL_DOIT

690

Chapter 2: ENVI Routines

TMCAL_DOIT
Use this program to calibrate Landsat TM data to radiance or reflectance using prelaunch characteristics.

Syntax
ENVI_DOIT, TMCAL_DOIT

Keywords
BIAS
Use this keyword to specify the calibration bias values for Landsat 7. This keyword is
not used for other satellites. BIAS is used with GAIN to convert the data.
result=Input * GAIN + BIAS

CAL_TYPE
Use this keyword to specify the calibration type. Set CAL_TYPE equal to zero to
indicate Radiance or to one to indicate Reflectance.

DATE
Use this keyword to specify the calibration numbers to use, depending on the date the
data was collected. When calibrating Landsat TM 7 data and you want to compute the
Earth-Sun distance, set the DATE keyword to an array of [month, day, year]
specifying the acquisition date. Choose one of the following:
Value

Definition

Before August 1983

Before January 15, 1984

After January 15, 1984


Table 36-12: DATE Keyword Values

TMCAL_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

691

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

GAIN
Use this keyword to specify the calibration gain values for Landsat 7. This keyword
is not used for other satellites. GAIN is used with BIAS to convert the data.
result=Input * GAIN + BIAS.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.
ENVI Reference Guide

TMCAL_DOIT

692

Chapter 2: ENVI Routines

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

SAT
Set this keyword to one of the following values to indicate the satellite type:
Value

Definition

Landsat 4

Landsat 5

Landsat 7

Table 36-13: SAT Keyword Values

SUN_ANGLE
Use this keyword to specify a floating-point value between 0.0 and 90.0
corresponding to the sun elevation angle. Sun elevation is only used for reflectance
calibration.

Example
pro example_tmcal_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, can_tmr.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;

TMCAL_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

693

; Set the DIMS and POS to keywords


; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
envi_file_query, fid, ns=ns, nl=nl, nb=nb
dims = [-1, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
bands_present = [0,1,2,3,4,6]
out_name = testimg
;
; Perform the TM Calibration
;
envi_doit, tmcal_doit, $
fid=fid, pos=pos, dims=dims, $
bands_present=bands_present, $
sat=4, cal_type=1, date=0, $
sun_angle=38.0, out_name=out_name, $
r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

TMCAL_DOIT

694

Chapter 2: ENVI Routines

TOPO_DOIT
Use this program to perform topographic modeling of a DEM image file.

Syntax
ENVI_DOIT, TOPO_DOIT

Keywords
AZIMUTH
Use this keyword to specify the sun azimuth for the purpose of sun shading.

BPTR (optional)
Use this keyword to specify the array of images to generate. Setting the elements of
the BPTR array to the values shown below will generate that image. For example, to
generate only the Slope and Shaded Relief images, set BPTR = [0,2].
Value

Definition

Slope

Aspect

Shaded Relief

Profile Convexity,

Plan Convexity

Longitudinal Convexity,

Cross Sectional Convexity

Minimum Curvature

Maximum Curvature

RMS

Table 36-14: BPTR Keyword Values


If this keyword is unspecified then all images will be generated.

TOPO_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

695

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

ELEVATION
Use this keyword to specify the sun elevation for the purpose of sun shading.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

PIXEL_SIZE
Use this keyword to specify a two-element array containing the X and Y pixel sizes,
respectively. The pixel size should be in the same units as the DEM.

ENVI Reference Guide

TOPO_DOIT

696

Chapter 2: ENVI Routines

POS
Use this keyword to specify a single band position, indicating the band number on
which to perform the operation. POS is a one element long integer array, the range on
the value is from zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Example
forward_function envi_get_projection
pro example_topo_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, bhdemsub.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS keyword to process
; all the spatial data and set
; the POS keyword to use the
; first band from the file.
; We will calculate the slope,
; aspect, and shaded relief images.
; Since the data file is
; georeferenced we can use the
; pixel size from the projection.
; The result will be saved to disk.
;
envi_file_query, fid, ns=ns, nl=nl
dims = [-1l, 0, ns-1, 0, nl-1]

TOPO_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

697

pos = [0]
bptr = [0,1,2]
out_bname = [Slope, Aspect, $
Shaded Relief]
proj = envi_get_projection(fid=fid, $
pixel_size=pixel_size)
out_name = testimg
;
; Call the topographic processing
; routine. Use a sun elevation of
; 67 degrees and an azimuth of 23
; degrees.
;
envi_doit, topo_doit, $
fid=fid, pos=pos, dims=dims, $
azimuth=23.0, elevation=67.0, $
bptr=bptr, out_name=out_name, $
out_bname=out_bname, $
pixel_size=pixel_size, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

ENVI Reference Guide

TOPO_DOIT

698

Chapter 2: ENVI Routines

TOPO_FEATURE_DOIT
Use this program to create a topographic feature classification image. Each pixel is
classified into one of the following terrain types or morphometric features: peak,
ridge, pass, plane, channel, or pit as controlled by the setting of CPTR.

Syntax
ENVI_DOIT, TOPO_FEATURE_DOIT

Keywords
CLASS_NAMES
Use this keyword to specify names for each output class. CLASS_NAMES is an
array of strings with num_classes+1 elements. Remember to set the zero class to
Unclassified.

CONVEX_TOL
Use this keyword to specify the floating-point or double-precision value for the
curvature tolerance. CONVEX_TOL and SLOPE_TOL in addition to the topographic
modeling values determine how a pixel is classified.

CPTR
Use this keyword to specify the output classes, peak, ridge, pass, plane, channel, or
pit, to compute. CPTR is an long array equal of values for each of the output classes
to compute. The possible values and the corresponding classes for CPTR are:
Value

Description

Peak

Ridge

Pass

Plane

Channel

Table 36-15: CPTR Keyword Values

TOPO_FEATURE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

699

Value
5

Description
Pit

Table 36-15: CPTR Keyword Values (Continued)

DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]:Unused for this function, set to -1.

DIMS[1]:The starting X pixel. (The first pixel is number zero.)

DIMS[2]:The ending X pixel.

DIMS[3]:The starting Y pixel. (The first pixel is number zero.)

DIMS[4]:The ending Y pixel.

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

KERNEL_SIZE
Use this keyword to specify a kernel size for the topographic features.
KERNEL_SIZE is a single scalar that set both the X and Y kernel size.
KERNEL_SIZE determines the local surface fit size used to calculate topographic
modeling parameters for feature extraction.

LOOKUP
Use this keyword to specify an array specifying the color tables for the classification
image. Each output class can have a unique color triple [r, g, b], LOOKUP is a byte
array of size (3, num_classes+1). Remember that class zero must also have a color
triplet (commonly black [0,0,0]).

ENVI Reference Guide

TOPO_FEATURE_DOIT

700

Chapter 2: ENVI Routines

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

PIXEL_SIZE
Use this optional keyword to specify the pixel size of the image. PIXEL_SIZE is a
two element floating or double precision array specifying the X and Y pixel size
respectively.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID (optional)
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

SLOPE_TOL
Use this keyword to specify the floating-point or double-precision value for the slope
tolerance. SLOPE_TOL and CONVEX_TOL in addition to the topographic modeling
values determine how a pixel is classified.

Example
forward_function envi_get_projection
pro example_topo_feature_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt

TOPO_FEATURE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

701

;
; Open the input file
;
envi_open_file, bhdemsub.img, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS keyword to process
; all the spatial data and set
; the POS keyword to use the
; first band from the file.
; Since the data file is
; georeferenced we can use the
; pixel size from the projection.
; The result will be saved to disk.
; Use a 7x7 kernel with a slope
; tolerance of 1.0 and a convex
; tolerance of 0.1
;
envi_file_query, fid, ns=ns, nl=nl, $
sname=sname
dims = [-1l, 0, ns-1, 0, nl-1]
pos = [0]
out_name = testimg
proj = envi_get_projection(fid=fid, $
pixel_size=pixel_size)
kernel_size = 7L
slope_tol = 1.0
convex_tol = .1
;
; We will classify all feature (peak,
; ridge, pass, plane, channel and pit)
; names - CPTR keyword. Set the output
; band name, class names and class
; colors.
;
cptr = bytarr(6) + 1b
out_bname = Topographic Features ( + $
sname + )
class_names = [Unclassified, Peak, $
Ridge, Pass, Plane, Channel, $
Pit]
lookup = bytarr(3,7)
for i=0, 6 do begin
envi_get_rgb_triplets, i+2, r, g, b
lookup[0,i] = [r,g,b]
endfor

ENVI Reference Guide

TOPO_FEATURE_DOIT

702

Chapter 2: ENVI Routines


;
; Call the topographic feature
; classification routine.
;
envi_doit,topo_feature_doit, $
fid=fid, pos=pos, dims=dims, $
kernel_size=kernel_size, $
slope_tol=slope_tol, $
convex_tol=convex_tol, $
pixel_size=pixel_size, $
out_name=out_name, cptr=cptr, $
out_bname=out_bname, $
class_names=class_names, $
lookup=lookup, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

See Also
TOPO_DOIT

TOPO_FEATURE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

703

UNMIX_DOIT
Use this program to perform Linear Spectral Unmixing.

Syntax
ENVI_DOIT, UNMIX_DOIT

Keywords
DIMS
Use this keyword to specify the spatial dimensions on which to perform the
operation. DIMS is a five-element array of long integers with the following
definitions:

DIMS[0]: Unused for this function, set to -1.

DIMS[1]: The starting X pixel. (The first pixel is number zero.)

DIMS[2]: The ending X pixel.

DIMS[3]: The starting Y pixel. (The first pixel is number zero.)

DIMS[4]: The ending Y pixel.

ENDMEM
Use this keyword to specify a floating-point array of the end members to unmix with.
This array must already be resampled to the correct wavelength to the data. The
dimensions of ENDMEM are (nb, num_endmem).

FID
Use this keyword to specify the file ID for the open file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

IN_MEMORY
Set this keyword to specify that output should be stored in memory. If IN_MEMORY
is not set, output will be stored on disk.

ENVI Reference Guide

UNMIX_DOIT

704

Chapter 2: ENVI Routines

M_FID
Use this keyword to specify the file ID for the mask file. This is the value returned
from the keyword R_FID in the ENVI_OPEN_FILE procedure. FID is a long integer
with a value greater than zero. An invalid file ID is specified as -1.

M_POS
Use this keyword to specify the band position of the mask band. M_POS is a single
long value greater than or equal to zero.

OUT_NAME
Use this keyword to specify an output file name for the resulting data. If the keyword
IN_MEMORY is set, this keyword is not needed.

OUT_BNAME
Use this keyword to specify a string array of output band names, if desired.

POS
Use this keyword to specify an array of band positions, indicating the band numbers
on which to perform the operation. POS is an array of long integers, ranging from
zero to the number of bands-1.

R_FID
Use this keyword to specify a named variable that will contain the file ID for the
processed data. This file ID can be used to access the processed data.

Weight (optional)
Use this optional keyword to specify a weight when applying a unit sum constraint.
WEIGHT is a floating point value greater than zero.

UNMIX_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

705

Example
pro example_unmix_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Open the input file
;
envi_open_file, mof94av.bil, r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
;
; Set the DIMS and POS to keywords
; to processes all spatial and all
; spectral data. Output the result
; to disk.
;
envi_file_query, fid, ns=ns, nl=nl, $
nb=nb
dims = [-1l, 0, ns-1, 0, nl-1]
pos = lindgen(nb)
out_name = testimg
;
; Read in the endmember text file.
; The first column are the
; wavelengths and the next 19
; columns are the endmembers. We will
; use the 19 endmembers for unmixing.
; The endmember data must also be
; transposed in order to send in
; a (nb, # endmember) array.
;
envi_read_cols, m94_em.asc, $
endmem, skip=em_names, /read_skip
endmem = transpose(endmem[1:*,*])
out_bname = [Unmix EM: + $
em_names[2:*], RMS Error]
;
; Call the Unmixing processing

ENVI Reference Guide

UNMIX_DOIT

706

Chapter 2: ENVI Routines


; routine.
;
envi_doit,unmix_doit, $
fid=fid, pos=pos, dims=dims, $
endmem=endmem, out_name=out_name, $
out_bname=out_bname, $
in_memory=0, r_fid=r_fid
;
; Exit ENVI
;
envi_batch_exit
end

UNMIX_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

707

VAX_IEEE_DOIT
Use this program to perform VAX IEEE floating point conversion.

Syntax
ENVI_DOIT, VAX_IEEE_DOIT

Keywords
IN_NAME
Use this keyword to specify an input file name for the VAX IEEE data.

OUT_NAME
Use this keyword to specify an output file name for the resulting data.

OFFSET
Use this keyword to specify a byte offset to the start of the VAX IEEE floating point
data.

COPY_HEADER
Set this keyword to specify that the header should be copied to the new output file.

Example
pro example_vax_ieee_doit
;
; First restore all the base save files.
;
envi, /restore_base_save_files
;
; Initialize ENVI and send all errors
; and warnings to the file batch.txt
;
envi_batch_init, log_file=batch.txt
;
; Set the input VAX filename.
;
offset = 0L
in_name = vaxdata
out_name = testimg

ENVI Reference Guide

VAX_IEEE_DOIT

708

Chapter 2: ENVI Routines


;
; Perform the VAX IEEE conversion.
;
envi_doit, vax_ieee_doit, $
in_name=in_name, out_name=out_name, $
offset=offset
;
; Exit ENVI
;
envi_batch_exit
end

VAX_IEEE_DOIT

ENVI Reference Guide

Chapter 2: ENVI Routines

709

WIDGET_AUTO_BASE
The WIDGET_AUTO_BASE function is used to create the top level base widget for
any auto-managed ENVI widget.
Note
An interactive ENVI session is required to run this routine.
The returned value of this function is the widget ID of the newly-created base.

Syntax
Result = WIDGET_AUTO_BASE()

Keywords
GROUP (optional)
The widget ID of an existing widget that serves as group leader for the newlycreated widget. When a group leader is killed, for any reason, all widgets in the group
are also destroyed.
A given widget can be in more than one group. The WIDGET_CONTROL procedure
can be used to add additional group associations to a widget. It is not possible to
remove a widget from an existing group.

TITLE (optional)
A string containing the title to be used for the top-level widget.

XBIG (optional)
Set this optional keyword if the widget will be large in the horizontal direction.

YBIG (optional)
Set this optional keyword if the widget will be large in the vertical direction.

ENVI Reference Guide

WIDGET_AUTO_BASE

710

Chapter 2: ENVI Routines

Example
; *******************************************************
; This routine is an example of how to select multiple
; ROIs using a compound widget.
;
; For more information see the ENVI Programmers Guide.
; *******************************************************
; Copyright (c) 2000-2001, Research Systems, Inc.
; *******************************************************
pro roi_multi_sel
envi_select, title=Input Filename, fid=fid
if (fid eq -1) then return
roi_ids = envi_get_roi_ids(fid=fid, roi_names=roi_names)
if (roi_ids[0] eq -1) then begin
print, No regions associated with the selected file
return
endif
; Compound widget for ROI selection
base = widget_auto_base(title=ROI Selection)
wm
= widget_multi(base, list=roi_names, uvalue=list, /auto)
result = auto_wid_mng(base)
if (result.accept eq 0) then return
ptr = where(result.list eq 1)
print, roi_names[ptr]
print, roi_ids[ptr]
end

WIDGET_AUTO_BASE

ENVI Reference Guide

Chapter 2: ENVI Routines

711

WIDGET_BASE
The WIDGET_BASE function is used to create base widgets. Base widgets serve as
containers for other widgets.
Note
An interactive ENVI session is required to run this routine.
The returned value of this function is the widget ID of the newly-created base.
Note
This function has been partially documented here for the convenience of the user,
for a complete list of arguments and keywords for WIDGET_BASE see the IDL
Reference Guide.

Syntax
Result = WIDGET_BASE([Parent])

Note
Arguments
Parent
The widget ID of the parent widget. To create a top-level base, omit the Parent
argument.

Keywords
COLUMN
If this keyword is included, the base lays out its children in columns. The value of
this keyword specifies the number of columns to be used. When one column is filled,
a new one is started.

ENVI Reference Guide

WIDGET_BASE

712

Chapter 2: ENVI Routines

Note
The standard base widget does not impose any placement constraints on its child
widgets. However, laying out widgets using the XSIZE, YSIZE, XOFFSET, and
YOFFSET keywords can be both tedious and error-prone. Also, if you want your
widget application to display properly on different platforms, you should use the
COLUMN and ROW keywords to influence child widget layouts instead of
explicitly formatting your interfaces.

EVENT_FUNC
A string containing the name of a function to be called by the WIDGET_EVENT
function when an event arrives from a widget in the widget hierarchy rooted at the
newly-created widget.

EVENT_PRO
A string containing the name of a procedure to be called by the WIDGET_EVENT
function when an event arrives from a widget in the widget hierarchy rooted at the
newly-created widget.

EXCLUSIVE
Set this keyword to specify that the base can have only button-widget children and
that only one button can be set at a time. These buttons, unlike normal button
widgets, have two states-set and unset.
When one exclusive button is pressed, any other exclusive buttons (in the same base)
that are currently set are automatically released. Hence, only one button can ever be
set at one time.

FRAME
The value of this keyword specifies the width of a frame (in pixels) to be drawn
around the borders of the widget. Note that this keyword is only a hint to the toolkit,
and may be ignored in some instances.

FUNC_GET_VALUE
A string containing the name of a function to be called when the GET_VALUE
keyword to the WIDGET_CONTROL procedure is called for this widget. Using this
technique allows you to change the value that should be returned for a widget.
Compound widgets use this ability to define their values transparently to the user.

WIDGET_BASE

ENVI Reference Guide

Chapter 2: ENVI Routines

713

GROUP_LEADER
The widget ID of an existing widget that serves as group leader for the newlycreated widget. When a group leader is killed, for any reason, all widgets in the group
are also destroyed.
A given widget can be in more than one group. The WIDGET_CONTROL procedure
can be used to add additional group associations to a widget. It is not possible to
remove a widget from an existing group.

MAP
Once a widget hierarchy has been realized, it can be mapped (visible) or unmapped
(invisible). This keyword specifies the initial map state for the given base and its
descendants. Specifying a non-zero value indicates that the base should be mapped
when realized (the default). A zero value indicates that the base should be unmapped
initially. After the base is realized, its map state can be altered using the MAP
keyword to the WIDGET_CONTROL procedure.

MBAR
Set this keyword to a named variable to cause a menu bar to be placed at the top of
the base (the base must be a top-level base). The menu bar is itself a special kind of
base widget that can only have buttons as children. Upon return, the named variable
contains the widget ID of the new menu bar base. This widget ID can then be used to
fill the menu bar with pulldown menus.

NO_COPY
Usually, when the SET_UVALUE, GET_UVALUE, or SEND_EVENT keywords are
used, the source variable memory is copied. When the NO_COPY keyword is set, the
source variable dynamic memory is used by the destination, without copying. This
feature can be used by compound widgets to obtain state information from a
UVALUE without all the memory copying that would otherwise occur.

NONEXCLUSIVE
Set this keyword to specify that the base can only have button widget children. These
buttons, unlike normal button widgets, have two states-set and unset.
Non-exclusive bases allow any number of the toggle buttons to be set at one time.

ENVI Reference Guide

WIDGET_BASE

714

Chapter 2: ENVI Routines

PRO_SET_VALUE
A string containing the name of a procedure to be called when the SET_VALUE
keyword to the WIDGET_CONTROL procedure is called for this widget. Using this
technique allows you to designate a routine that sets the value for a widget.
Compound widgets use this ability to define their values transparently to the user.

ROW
If this keyword is included, the base lays out its children in rows. The value of this
keyword specifies the number of rows to be used. When one row is filled, a new one
is started.
This keyword is similar to the COLUMN keyword described above.

TITLE
A string containing the title to be used for the widget. Base widgets use the title only
if they are top-level widgets.

UVALUE
The user value to be assigned to the widget.
Each widget can contain a user-specified value of any data type and organization.
This value is not used by the widget in any way, but exists entirely for the
convenience of the IDL programmer. This keyword allows you to set this value when
the widget is first created.
If UVALUE is not present, the widget's initial user value is undefined.
The user value for a widget can be accessed and modified at any time by using the
GET_UVALUE and SET_UVALUE keywords to the WIDGET_CONTROL
procedure.

XOFFSET
The horizontal offset of the widget (in pixels) relative to its parent.
Specifying an offset relative to a row or column major base widget does not work
because those widgets enforce their own layout policies. This keyword is primarily of
use relative to a plain base widget. Note that it is best to avoid using this style of
widget layout.

WIDGET_BASE

ENVI Reference Guide

Chapter 2: ENVI Routines

715

XSIZE
The width of the widget (in pixels for most widgets, in characters for text widgets).
Most widgets attempt to size themselves to fit the situation. However, if the desired
effect is not produced, use this keyword to override it. This keyword is only a hint
to the toolkit and may be ignored in some situations.

YOFFSET
The vertical offset of the widget (in pixels) relative to its parent. This offset is
specified relative to the upper left corner of the parent widget.
Specifying an offset relative to a row or column major base widget does not work
because those widgets enforce their own layout policies. This keyword is primarily of
use relative to a plain base widget. Note that it is best to avoid using this style of
widget layout.

YSIZE
The height of the widget (in pixels for most widgets, in characters for text widgets, in
number of visible items for list widgets).
Most widgets attempt to size themselves to fit the situation. However, if the desired
effect is not produced, use this keyword to override it. This keyword is only a hint
to the toolkit and may be ignored in some situations.

Widget Events
Top-level widget bases return the following event structure only when they are
resized by the user and the base was created with the TLB_SIZE_EVENTS keyword
set:
{WIDGET_BASE, ID:0L, TOP:0L, HANDLER:0L, X:0, Y:0 }

ID is the widget ID of the base generating the event. TOP is the widget ID of the top
level widget containing ID. HANDLER contains the widget ID of the widget
associated with the handler routine. The X and Y fields return the new width of the
base, not including any frame provided by the window manager.

ENVI Reference Guide

WIDGET_BASE

716

Chapter 2: ENVI Routines

WIDGET_CONTROL
The WIDGET_CONTROL procedure is used to realize, manage, and destroy widget
hierarchies.
Note
An interactive ENVI session is required to run this routine.
This routine is often used to change the default behavior or appearance of previouslyrealized widgets.
Note
This function has been partially documented here for the convenience of the user,
for a complete list of arguments and keywords for WIDGET_CONTROL see the
IDL Reference Guide.

Syntax
WIDGET_CONTROL [, Widget_ID]

Arguments
Widget_ID
The widget ID of the widget to be manipulated. This argument can be omitted when
used with the RESET keyword, but is required for all other operations.

Keywords
DESTROY
Set this keyword to destroy the widget and any child widgets in its hierarchy. Any
further attempts to use the IDs for these widgets will cause an error.

EVENT_FUNC
A string containing the name of a function to be called by the WIDGET_EVENT
function when an event arrives from a widget in the widget hierarchy given by
Widget_ID.

WIDGET_CONTROL

ENVI Reference Guide

Chapter 2: ENVI Routines

717

This keyword overwrites any event routine supplied by previous uses of the
EVENT_FUNC or EVENT_PRO keywords. To specify no event routine, set this
keyword to a null string ().

EVENT_PRO
A string containing the name of a procedure to be called by the WIDGET_EVENT
function when an event arrives from a widget in the widget hierarchy given by
Widget_ID.
This keyword overwrites any event routine supplied by previous uses of the
EVENT_FUNC or EVENT_PRO keywords. To specify no event routine, set this
keyword to a null string ().

FUNC_GET_VALUE
A string containing the name of a function to be called when the GET_VALUE
keyword to the WIDGET_CONTROL procedure is called for this widget. Using this
technique allows you to change the value that should be returned for a widget.
Compound widgets use this ability to define their values transparently to the user.

GET_UVALUE
Set this keyword to a named variable to contain the current user value of the widget.
Each widget can contain a user set value of any data type and organization. This
value is not used by the widget in any way, and exists entirely for the convenience of
the IDL programmer. This keyword allows you to obtain the current user value.
The user value of a widget can be set with the SET_UVALUE keyword to this
routine, or with the UVALUE keyword to the routine that created it.
To improve the efficiency of the data transfer, consider using the NO_COPY
keyword (described below) with GET_UVALUE.

GET_VALUE
Set this keyword to a named variable to contain the current value of the widget. The
type of value returned depends on the widget type:

Button: If the button label is text, it is returned as a string. Attempts to obtain


the value of a button with a bitmap label is an error.

Draw: The IDL window ID for the drawing area is returned. This ID is used
with procedures such as WSET, WSHOW, etc., to direct graphics to the
widget. The window ID is assigned to drawing area widgets at the time they
are realized. If the widget has not yet been realized, a value of -1 is returned.

ENVI Reference Guide

WIDGET_CONTROL

718

Chapter 2: ENVI Routines

Label: The label text is returned as a string.

Slider: The current value of the slider is returned as an integer.

Text: The current contents of the text widget are returned as a string array. If
the USE_TEXT_SELECT keyword is also specified, only the contents of the
current selection are returned.

Widget types not listed above do not return a value. Attempting to retrieve the
value of such a widget causes an error.

The value of a widget can be set with the SET_VALUE keyword to this routine, or
with the VALUE keyword to the routine that created it.

GROUP_LEADER
The widget ID of an existing widget that serves as group leader for the newlycreated widget. When a group leader is killed, for any reason, all widgets in the group
are also destroyed.
A given widget can be in more than one group. The WIDGET_CONTROL procedure
can be used to add additional group associations to a widget. It is not possible to
remove a widget from an existing group.

HOURGLASS
Set this keyword to turn on an hourglass-shaped cursor for all IDL widgets and
graphics windows. The hourglass remains in place until the WIDGET_EVENT
function attempts to process the next event. Then the previous cursor is reinstated. If
an application starts a time-intensive calculation inside an event-handling routine, the
hourglass cursor should be used to indicate that the system is not currently
responding to events.

ICONIFY
Set this keyword to a non-zero value to cause the specified widget to become
iconified. Set this keyword to zero to open an iconified widget.

INPUT_FOCUS
If Widget_ID is a text widget, you can set this keyword to cause the widget to receive
the keyboard focus. If Widget_ID is a button widget, set this keyword to position the
mouse pointer over the button (on UNIX, Mac OS X), or set the focus to the button so
that it can be pushed with the spacebar (on Windows). This keyword has no effect
for other widget types.

WIDGET_CONTROL

ENVI Reference Guide

Chapter 2: ENVI Routines

719

MAP
Set this keyword to zero to unmap the widget hierarchy rooted at the widget specified
by Widget_ID. The hierarchy disappears from the screen, but still exists.
The mapping operation applies only to base widgets. If the specified widget is not a
base, IDL searches upward in the widget hierarchy until it finds the closest base
widget. The map operation is applied to that base.
Set MAP to a nonzero value to re-map the widget hierarchy and make it visible.
Normally, the widget is automatically mapped when it is realized, so use of the MAP
keyword is not required.

NO_COPY
Usually, when the SET_UVALUE, GET_UVALUE, or SEND_EVENT keywords are
used, the source variable memory is copied. When the NO_COPY keyword is set, the
source variable dynamic memory is used by the destination, without copying. This
feature can be used by compound widgets to obtain state information from a
UVALUE without all the memory copying that would otherwise occur.
Note that when the NO_COPY keyword is set, data is taken away from the source
and attached directly to the destination. This feature can be used to move data very
efficiently. However, it has the side effect of causing the source variable to become
undefined.

PRO_SET_VALUE
A string containing the name of a procedure to be called when the SET_VALUE
keyword to the WIDGET_CONTROL procedure is called for this widget. Using this
technique allows you to designate a routine that sets the value for a widget.
Compound widgets use this ability to define their values transparently to the user.

REALIZE
If set, the widget hierarchy is realized. Until the realization step, the widget hierarchy
exists only within IDL. Realization is the step of actually creating the widgets on the
screen (and mapping them if necessary).
When a previously-realized widget gets a new child widget, the new child is
automatically realized.

ENVI Reference Guide

WIDGET_CONTROL

720

Chapter 2: ENVI Routines

SENSITIVE
When a widget is sensitive, it has normal appearance and can receive user input. For
instance, a sensitive button widget can be activated by moving the mouse cursor over
it and pressing a mouse button. When a widget is insensitive, it indicates the fact by
changing its appearance, and ignores any input directed at it. If SENSITIVE is zero,
the widget hierarchy becomes insensitive. If nonzero, it becomes sensitive.
Sensitivity can be used to control when a user is allowed to manipulate a widget. It
should be noted that some widgets do not change their appearance when they are
made insensitive, and simply cease generating events.

SET_UVALUE
Each widget can contain a user-set value. This value is not used by IDL in any way,
and exists entirely for the convenience of the IDL programmer. This keyword allows
you to set this value.
To improve the efficiency of the data transfer, consider using the NO_COPY
keyword with SET_UVALUE.

SET_VALUE
Sets the value of the specified widget. The meaning of the value differs between
widget types:

Button: The label to be used for the button. This value can be either a scalar
string, or a 2D byte array containing a bitmap.

Label: The text to be displayed by the label widget.

List: Set the selections for the list widget (string or string array).

Slider: Sets the current position of the slider (integer).

Text: Set the text to be displayed. If the APPEND keyword is also specified,
the text is appended to the current contents instead of instead of completely
replacing it (string or string array). If the USE_TEXT_SELECT keyword is
specified, the new string replaces only the currently-selected text in the text
widget.

Widget types not listed above do not allow the setting of a value. Attempting to
set the value of such a widget causes an error.

The value of a widget can also be set with the VALUE keyword to the routine that
created it.

WIDGET_CONTROL

ENVI Reference Guide

Chapter 2: ENVI Routines

721

XOFFSET
Set this keyword to an integer value that specifies the widgets new horizontal offset,
in pixels. Attempting to change the offset of a widget that is the child of a ROW or
COLUMN base or a widget that is part of a menu bar or pulldown menu causes an
error.

XSIZE
Set this keyword to an integer value that represents the widgets new horizontal size
in pixels for most widgets, but in characters for text or list widgets. For most nonscrollable widgets, this size is the same as the screen size that can be set using the
SCR_XSIZE keyword. For scrollable widgets (e.g., scrolling bases and scrolling
draw widgets), this keyword adjusts the viewport size. Use the DRAW_XSIZE
keyword to change the width of the drawing area in scrolling draw widgets.
Attempting to resize a widget that is part of a menubar or pulldown menu causes an
error.

YOFFSET
Set this keyword to an integer value that specifies the widget's new vertical offset, in
pixels. Attempting to change the offset of a widget that is the child of a ROW or
COLUMN base or a widget that is part of a menu bar or pulldown menu causes an
error.

YSIZE
Set this keyword to an integer value that represents the widget's new vertical size in
pixels for most widgets, but in characters for text or list widgets. For most nonscrollable widgets, this size is the same as the screen size that can be set using the
SCR_YSIZE keyword. For scrollable widgets (e.g., scrolling bases and scrolling
draw widgets), this keyword adjusts the viewport size. Use the DRAW_YSIZE
keyword to change the height of the drawing area in scrolling draw widgets.
Attempting to resize a widget that is part of a menu bar or pulldown menu causes an
error.

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
WIDGET_BASE

ENVI Reference Guide

WIDGET_CONTROL

722

Chapter 2: ENVI Routines

WIDGET_EDIT
The WIDGET_EDIT compound widget is used to edit multiple values from lists. The
function returns the base ID of the widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_EDIT(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
AUTO_MANAGE (optional)
Use this optional keyword to specify how ENVI auto manages the widget with
AUTO_WID_MNG. The keyword value specifies if the widget must have a defined
value. Setting this keyword to 1 requires that the widget has either a default value
or a user-entered value. Setting this keyword to 0 does not require a value. Do not
use this keyword for user-managed widgets.

CEIL (optional)
Use this optional keyword to specify a maximum value allowed for input numbers.
CEIL is only valid when the VALS keyword is specified.

DT (optional)
Use this optional keyword to specify the IDL data type of the edit values, using the
following IDL convention:

WIDGET_EDIT

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

ENVI Reference Guide

Chapter 2: ENVI Routines

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

723

FIELD (optional)
Use this optional keyword to specify the number of decimal places to use when
formatting numbers. This keyword has no effect unless the data type is 4 (float) or
greater. FIELD is only valid when the VALS keyword is specified.

FLOOR (optional)
Use this optional keyword to specify a minimum value allowed for input numbers.
FLOOR is only valid when the VALS keyword is specified.

FRAME (optional)
Set this optional keyword to draw a frame around the widget.

LIST
Use this keyword to specify a string array of items to edit. If the VAL keyword is
specified then LIST is the tag name associated with each value.

PROMPT (optional)
Use this optional keyword to specify the prompt string to be used for the widget.

SELECT_PROMPT (optional)
Use this optional keyword to specify a prompt string associated with the item being
edited.

ENVI Reference Guide

WIDGET_EDIT

724

Chapter 2: ENVI Routines

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.
For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag
name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

VALS (optional)
Use this optional keyword to provide an array of values to edit. The presence of this
keyword requires that a string identifier be associated with each value.

XSIZE (optional)
Use this optional keyword to specify the width of the widget, in characters.

YSIZE (optional)
Use this optional keyword to specify the height of the widget, in characters.

Widget Event
When the widget is not auto managed, widget events set event.result to the
edited list or, if VAL is specified, to the array of edited numbers. Input numbers are
always returned as double precision regardless of the value of the DT keyword.
Widget events occur any time an edit takes place.

Example
Create a simple compound widget for editing multiple values from a list. Print out the
final edited list.
base = widget_auto_base(title=Edit test)
list = [Item A , Item B , Item C , Item D ]
vals = [10.0, 20.0, 30.0, 40.0]

we = widget_edit(base, uvalue=edit', list'=list, $


vals=vals, /auto)
result = auto_wid_mng(base)
if (result.accept eq 0) then return
print, New Values, result.edit

WIDGET_EDIT

ENVI Reference Guide

Chapter 2: ENVI Routines

725

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
WIDGET_PARAM

ENVI Reference Guide

WIDGET_EDIT

726

Chapter 2: ENVI Routines

WIDGET_GEO
The WIDGET_GEO compound widget is used to specify Latitude and Longitude
values. The function returns the base ID of the widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_GEO(Base)

Arguments
Base
The widget ID of the widget base.

Keywords
AUTO_MANAGE (optional)
Use this optional keyword to specify how ENVI auto manages the widget with
AUTO_WID_MNG. The keyword value specifies if the widget must have a defined
value. Setting this keyword to 1 requires that the widget has either a default value
or a user-entered value. Setting this keyword to 0 does not require a value. Do not
use this keyword for user-managed widgets.

DEFAULT (optional)
Set this optional keyword to specify the default Latitude and Longitude in decimal
degrees. DEFAULT is a two element float array. If LAT_ONLY is set then DEFAULT
is a single element float array.

DMS (optional)
Set this optional keyword to specify that Latitude and Longitude in Degrees, Minutes
and Seconds. Set DMS to zero to allow decimal degrees. The default is to use
Degrees, Minutes and Seconds.

WIDGET_GEO

ENVI Reference Guide

Chapter 2: ENVI Routines

727

LAT_ONLY
Set this keyword to specify that only Latitude values are shown.

PROMPT (optional)
Use this optional keyword to specify a string array for the prompt string. If no values
are specified then the prompt array is set to [Lat, Lon]

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.
For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag
name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

Example
Create a simple compound widget to enter a Latitude and Longitude value. If the
values are entered successfully then print out the result.
base = widget_auto_base(title=Simple Lat/Lon)
wg = widget_geo(base, /dms, uvalue=geo, /auto)
result = auto_wid_mng(base)
if (result.accept eq 0) then return
print, Latitude: , result.geo[0]
print, Longitude: result.geo[1]

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
WIDGET_MAP

ENVI Reference Guide

WIDGET_GEO

728

Chapter 2: ENVI Routines

WIDGET_MAP
WIDGET_MAP is a specialized compound widget to allow input and edit of map
coordinates and projections.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_MAP(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
AUTO_MANAGE (optional)
Use this optional keyword to specify how ENVI auto manages the widget with
AUTO_WID_MNG. The keyword value specifies if the widget must have a defined
value. Setting this keyword to 1 requires that the widget has either a default value or a
user-entered value. Setting this keyword to 0 does not require a value. Do not use this
keyword for user-managed widgets.

DEFAULT_MAP (optional)
Use this optional keyword to set the default map location for the compound widget.
DEFAULT_MAP is a double array with the following values:

default_map(0) is the default X map location.

default_map(1) is the default Y map location.

DEFAULT_PROJ (optional)
Use this optional keyword to set the default map projection for the compound widget.
DEFAULT_PROJ is a projection structure returned from ENVI_GET_PROJECTION
or ENVI_PROJ_CREATE.

WIDGET_MAP

ENVI Reference Guide

Chapter 2: ENVI Routines

729

FLIP (optional)
Set this optional keyword to allow flipping between lat/long and map coordinates.

FRAME (optional)
Set this optional keyword to place a frame around the widget base.

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any data
type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.
For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag
name in the returned anonymous structure. For user-managed widget, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

Widget Event
When the widget is not auto managed, widget events set event.result to a
structure with three tags: map_x, map_y, and proj.

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
WIDGET_GEO

ENVI Reference Guide

WIDGET_MAP

730

Chapter 2: ENVI Routines

WIDGET_MENU
WIDGET_MENU is a specialized compound widget used to create a menu. The
function returns the base ID of the widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_MENU(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
AUTO_MANAGE (optional)
Use this optional keyword to specify how ENVI auto manages the widget with
AUTO_WID_MNG. The keyword value specifies if the widget must have a defined
value. Setting this keyword to 1 requires that the widget has either a default value
or a user-entered value. Setting this keyword to 0 does not require a value. Do not
use this keyword for user-managed widgets.

BUT_BASES (optional)
Use this optional keyword to specify a named variable to hold the returned array of
the widget ID of each button. Specifying this keyword allows you to manage each
button by making calls to WIDGET_CONTROL.

DEFAULT_ARRAY (optional)
Use this optional keyword to specify an array indicating the state of each button. A
one indicates the button is set, a zero indicates not set.

DEFAULT_PTR (optional)
Use this optional keyword to specify which single button should be set by default.
WIDGET_MENU

ENVI Reference Guide

Chapter 2: ENVI Routines

731

EXCLUSIVE (optional)
Set this optional keyword to make the menu items exclusive.

LIST
Use this keyword to specify an array of string values for the menu buttons.

PROMPT (optional)
Use this optional keyword to specify the prompt string to be used for the widget.

ROWS (optional)
Use this optional keyword to specify the number of rows for the menu. The
default is one.

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.
For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag
name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

Widget Event
When the widget is not auto managed, if EXCLUSIVE is set, event.result is set
to a single value indicating which button was pressed. If EXCLUSIVE is not set,
event.result is a byte array of zeros and ones where a one indicates a selected
button.

Example
Create a simple compound widget to select one item from a exclusive menu. If the
menu item is properly selected then print out the result.
base = widget_auto_base(title=Menu test)
list = [Button 1, Button 2, Button 3, Button 4]

wm = widget_menu(base, list=list, uvalue=menu, /excl, $


/auto)
result = auto_wid_mng(base)
if (result.accept eq 0) then return

ENVI Reference Guide

WIDGET_MENU

732

Chapter 2: ENVI Routines


print, Menu Selected, result.menu

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
WIDGET_PMENU

WIDGET_MENU

ENVI Reference Guide

Chapter 2: ENVI Routines

733

WIDGET_MULTI
WIDGET_MULTI is a compound widget that allows selection of multiple items from
a list. The function returns the base ID of the widget. This is the widget used for
spectral subsetting.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_MULTI(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
AUTO_MANAGE (optional)
Use this optional keyword to specify how ENVI auto manages the widget with
AUTO_WID_MNG. The keyword value specifies if the widget must have a defined
value. Setting this keyword to 1 requires that the widget has either a default value
or a user-entered value. Setting this keyword to 0 does not require a value. Do not
use this keyword for user-managed widgets.

BUTTON_BASES (optional)
Use this optional keyword to specify a named variable to hold the returned array of
the widget ID of each button. Specifying this keyword allows the user to manage
each button by making calls to WIDGET_CONTROL.

DEFAULT (optional)
Use this optional keyword to specify a byte array of zeros and ones indicating the
default selection state of each item in the multi list. A one indicates that the item is
selected, a zero indicates it is not selected.

ENVI Reference Guide

WIDGET_MULTI

734

Chapter 2: ENVI Routines

LIST
Use this keyword to specify an array of string values for the menu buttons.

NO_RANGE (optional)
Set this optional keyword to disable selection of items by specifying a range.

PROMPT (optional)
Use this optional keyword to specify the prompt string to be used for the widget.

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.
For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag
name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

YSIZE (optional)
Use this optional keyword to specify the height of the widget in pixels. The default is
350.

Widget Event
When the widget is not auto managed, widget events set event.result to an array
of zeros and ones, where a one indicates a selected item.

Example
Create a simple compound widget to select multiple items from a list. If the items are
properly selected then print out the result.
base = widget_auto_base(title=Multi test)
list = [Item 1, Item 2, Item 3, Item 4]

wm = widget_multi(base, list=list, uvalue=list, /auto)


result = auto_wid_mng(base)
if (result.accept eq 0) then return
print, Selected Items, where(result.list eq 1)

WIDGET_MULTI

ENVI Reference Guide

Chapter 2: ENVI Routines

735

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
WIDGET_SLIST

ENVI Reference Guide

WIDGET_MULTI

736

Chapter 2: ENVI Routines

WIDGET_OUTF
WIDGET_OUTF is an output file name selector that provides no option of output to
memory. The function returns the base ID of the widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_OUTF(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
AUTO_MANAGE (optional)
Use this optional keyword to specify how ENVI auto manages the widget with
AUTO_WID_MNG. The keyword value specifies if the widget must have a defined
value. Setting this keyword to 1 requires that the widget has either a default value
or a user-entered value. Setting this keyword to 0 does not require a value. Do not
use this keyword for user-managed widgets.

DIRECTORY (optional)
Set this optional keyword to allow selection of an output directory.

DEFAULT (optional)
Use this optional keyword to specify the default text string to place in the widget.

FUNC (optional)
Use this optional keyword to specify the name of a function to call with the input
string. This allows you to call a custom routine to validate inputs. A one is returned if
the entered filename is valid and zero otherwise.

WIDGET_OUTF

ENVI Reference Guide

Chapter 2: ENVI Routines

737

PROMPT (optional)
Use this optional keyword to specify the prompt string to be used for the widget.

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.
For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag
name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

XSIZE (optional)
Use this optional keyword to specify the width of the widget, in characters.

Widget Event
When the widget is not auto managed, widget events set event.result to the input
string.

Example
Create a simple compound widget to select a file. If the file is properly selected then
print out the filename.
base = widget_auto_base(title=File Selection test)
wo = widget_outf(base, uvalue=outf, /auto)
result = auto_wid_mng(base)
if (result.accept eq 0) then return
print, Selected File, result.outf

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
WIDGET_OUTFM

ENVI Reference Guide

WIDGET_OUTF

738

Chapter 2: ENVI Routines

WIDGET_OUTFM
WIDGET_OUTFM is an output file selector that includes the option of output to
memory. The function returns the base ID of the widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_OUTFM(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
AUTO_MANAGE (optional)
Use this optional keyword to specify how ENVI auto manages the widget with
AUTO_WID_MNG. The keyword value specifies if the widget must have a defined
value. Setting this keyword to 1 requires that the widget has either a default value
or a user-entered value. Setting this keyword to 0 does not require a value. Do not
use this keyword for user-managed widgets.

DEFAULT (optional)
Use this optional keyword to specify the default text string to place in widget.

FRAME (optional)
Set this optional keyword to place a frame around the widget base.

FUNC (optional)
Use this optional keyword to specify the name of a function to call with the input
string. This allows you to call a custom routine to validate inputs. A one is returned if
the entered filename is valid and zero otherwise.

WIDGET_OUTFM

ENVI Reference Guide

Chapter 2: ENVI Routines

739

PROMPT (optional)
Use this optional keyword to specify the prompt string to be used for the widget.

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.
For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag
name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

XSIZE (optional)
Use this optional keyword to specify the width of the widget, in characters.

Widget Event
When the widget is not auto managed, widget events set event.result to a
structure with two tags: name and in_memory. If in_memory is zero then
name is set to the input string. If in_memory is one then the user desires to leave
the output in memory and not write the result to a file.

Example
Create a simple compound widget to select a file/memory. If the file/memory is
properly selected then print out the result.
base = widget_auto_base(title=File/Memory Selection test)
wo = widget_outfm(base, uvalue=outf', /auto)
result = auto_wid_mng(base)
if (result.accept eq 0) then return
if ((result.outf.in_memory) eq 1) then $
print, Output to memory selected $
else $
print, Selected File, result.outf.name

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
WIDGET_OUTF

ENVI Reference Guide

WIDGET_OUTFM

740

Chapter 2: ENVI Routines

WIDGET_PARAM
WIDGET_PARAM is a compound widget used to enter a parameter. The function
returns the base ID of the widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_PARAM(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
AUTO_MANAGE (optional)
Use this optional keyword to specify how ENVI auto manages the widget with
AUTO_WID_MNG. The keyword value specifies if the widget must have a defined
value. Setting this keyword to 1 requires that the widget has either a default value
or a user-entered value. Setting this keyword to 0 does not require a value. Do not
use this keyword for user-managed widgets.

CEIL (optional)
Use this optional keyword to specify a maximum value allowed for input numbers.

COMMA (optional)
Set this optional keyword to format numbers with commas (i.e. 3,124,000).

CM (optional)
Set this optional keyword to cause the entered parameter to be annotated with cm.
CM cannot be used with INCHES or PERCENT.

WIDGET_PARAM

ENVI Reference Guide

Chapter 2: ENVI Routines

741

DEFAULT (optional)
Use this optional keyword to set the default value for the parameter.

DT (optional)
Use this optional keyword to specify a named variable that will contain the IDL data
type of the file, using the following IDL convention:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

FIELD (optional)
Use this optional keyword to specify the number of decimal places to use when
formatting numbers. This keyword has no effect unless the data type is 4 (float) or
greater.

FLOOR (optional)
Use this optional keyword to specify a minimum value allowed for input numbers.

INCHES (optional)
Set this optional keyword to cause the entered parameter to be annotated with "
(the inch symbol). INCHES cannot be used with CM or PERCENT.

PERCENT (optional)
Set this optional keyword to cause the entered parameter to be annotated with %
(the percent symbol). PERCENT cannot be used with CM or INCHES.
ENVI Reference Guide

WIDGET_PARAM

742

Chapter 2: ENVI Routines

PROMPT (optional)
Use this optional keyword to specify the prompt string to be used for the widget.

UNDEFINED (optional)
Use this optional keyword to specify the value returned when the parameter is
undefined. The default returned value is 10-34.

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.
For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag
name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

XSIZE (optional)
Use this optional keyword to specify the width of the widget, in characters.

Widget Event
When the widget is not auto managed, widget events set event.result to the value
of the input parameter. If the parameter is undefined then the value of the keyword
UNDEFINED is returned.
Note
The data type of event.result is always double. The user is responsible for
casting the return value to the appropriate data type.

Example
Create a simple compound widget for inputting one floating point parameter. If the
parameter is properly entered then print the result.
base = widget_auto_base(title=Parameter test)
we = widget_param(base, dt=4, field=3, floor=0., $
default=10., uvalue=param, /auto)
result = auto_wid_mng(base)
if (result.accept eq 0) then return
print, Parameter value = , float(result.param)

WIDGET_PARAM

ENVI Reference Guide

Chapter 2: ENVI Routines

743

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
WIDGET_EDIT

ENVI Reference Guide

WIDGET_PARAM

744

Chapter 2: ENVI Routines

WIDGET_PMENU
WIDGET_PMENU is a pulldown menu compound widget. The function returns the
base ID of the widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_PMENU(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
AUTO_MANAGE (optional)
Set this optional keyword to specify that the widget be managed by the ENVI
function AUTO_WID_MNG.

DEFAULT (optional)
Use this optional keyword to specify the index entry of the default menu selection.

LIST
Use this keyword to specify a string array of pulldown menu items. For the best
results, pad list items with spaces to make all items equal in length.

LOOKUP (optional)
Use this optional keyword to specify an array of values associated with each menu
item.

PROMPT (optional)
Use this optional keyword to specify the prompt string to be used for the widget.

WIDGET_PMENU

ENVI Reference Guide

Chapter 2: ENVI Routines

745

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.
For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag
name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

XSIZE (optional)
Use this optional keyword to specify the width of the widget, in characters.

Widget Event
When the widget is not auto managed, widget events set event.result to the index
of the selected menu item.

Example
Create a simple compound widget for a pulldown menu. If OK is selected then print
the menu item selected.
base = widget_auto_base(title=Menu test)
list = [Item 1, Item 2, Item 3, Item 4]

we = widget_pmenu(base, list=list, uvalue=menu, /auto)


result = auto_wid_mng(base)
if (result.accept eq 0) then return
print, Menu Item Selected= , list(result.menu)

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
WIDGET_MENU

ENVI Reference Guide

WIDGET_PMENU

746

Chapter 2: ENVI Routines

WIDGET_RGB
WIDGET_RGB is a compound widget to modify a color value associated with an rgb
using the RGB, HLS, or HSV color system. The function returns the base ID of the
widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_RGB(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
AUTO_MANAGE (optional)
Set this optional keyword to specify that the widget be managed by the ENVI
function AUTO_WID_MNG.

BIT_24 (optional)
Set this optional keyword to specify 24-bit color.

INDEX (optional)
Use this optional keyword to select the color table index to edit. The default is zero.

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.

WIDGET_RGB

ENVI Reference Guide

Chapter 2: ENVI Routines

747

For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag


name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

Widget Event
When the widget is not auto managed, widget events set event.result to a byte
array of three elements, RGB, regardless of the color system. User managed widgets
can use WIDGET_CONTROL SET_VALUE to change the color index being edited.
In this case, SET_VALUE should be set to a 3 element array of RGB values for the
current index. Optionally SET_VALUE can be set to a 4 element array where the
fourth value is a new color index to edit.
WIDGET_CONTROL GET_VALUE can be used to return the current RGB
3-element array. The inputs and output from SET_VALUE and GET_VALUE are
always RGB regardless of the color system selected.

Example
Create a simple compound widget to modify the fifth color in the ENVI graphic color
table. If the color is properly modified then output the new RGB color triplet.
base = widget_auto_base(title=RGB test)
we = widget_rgb(base, index=5, uvalue=rgb, /auto)
result = auto_wid_mng(base)
if (result.accept eq 0) then return
print, New RGB color triplet= , result.rgb

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
ENVI_GET_RGB_TRIPLETS

ENVI Reference Guide

WIDGET_RGB

748

Chapter 2: ENVI Routines

WIDGET_SLABEL
WIDGET_SLABEL is a compound widget used to display a string message with
scroll bars. The function returns the base ID of the widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_SLABEL(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
FRAME (optional)
Set this optional keyword to create a frame around the widget.

PROMPT (optional)
Use this optional keyword to specify the text to display.

XSIZE (optional)
Use this optional keyword to specify the width of the widget, in characters.

YSIZE (optional)
Use this optional keyword to specify the height of the widget, in characters.

Widget Event
This is a passive widget and does not generate events.

WIDGET_SLABEL

ENVI Reference Guide

Chapter 2: ENVI Routines

749

See Also
WIDGET_AUTO_BASE

ENVI Reference Guide

WIDGET_SLABEL

750

Chapter 2: ENVI Routines

WIDGET_SLIST
WIDGET_SLIST is a compound widget for creating lists. The function returns the
base ID of the widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_SLIST(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
AUTO_MANAGE (optional)
Use this optional keyword to specify how ENVI auto manages the widget with
AUTO_WID_MNG. The keyword value specifies if the widget must have a defined
value. Setting this keyword to 1 requires that the widget has either a default value
or a user-entered value. Setting this keyword to 0 does not require a value. Do not
use this keyword for user-managed widgets.

DEFAULT (optional)
Use this optional keyword to specify the list item that is selected by default.

FORCE (optional)
Set this optional keyword to maintain the width specified by the XSIZE keyword
when the NO_SELECT keyword is set. If the FORCE keyword is not set when the
XSIZE and NO_SELECT keywords are both set, the list widget size is then based on
the width of the widest item in the list.

FRAME (optional)
Set this optional keyword to create a frame around the compound widget.
WIDGET_SLIST

ENVI Reference Guide

Chapter 2: ENVI Routines

751

LIST
Use this keyword to specify a string array of items in the selection list.

NO_SELECT (optional)
Normally, the item selected from the list is displayed in a separate text box. Set this
optional keyword to prevent the selected item from being displayed outside the list.

PROMPT (optional)
Use this optional keyword to specify the prompt string to be used for the widget.

SELECT_PROMPT (optional)
Use this optional keyword to specify a string to be used as the prompt appearing in
the selection widget.

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.
For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag
name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

XSIZE (optional)
Use this optional keyword to specify the width of the widget, in characters.

YSIZE (optional)
Use this optional keyword to specify the height of the widget, in characters.

Widget Event
When the widget is not auto managed, widget events set event.result to the index
of the selected item.

ENVI Reference Guide

WIDGET_SLIST

752

Chapter 2: ENVI Routines

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
WIDGET_MULTI

WIDGET_SLIST

ENVI Reference Guide

Chapter 2: ENVI Routines

753

WIDGET_SSLIDER
WIDGET_SSLIDER is a compound widget for setting values using a slider. The
function returns the base ID of the widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_SSLIDER(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
AUTO_MANAGE (optional)
Set this optional keyword to specify that the widget be managed by the ENVI
function AUTO_WID_MNG.

CEIL (optional)
Use this optional keyword to specify a maximum value allowed for input numbers.
The returned value will always equal to or less than this number, even if the slider is
positioned higher.

DRAG (optional)
Set this optional keyword to cause events to be generated continuously while the
slider is being moved. For more information see the DRAG keyword to the IDL
WIDGET_SLIDER function.

ENVI Reference Guide

WIDGET_SSLIDER

754

Chapter 2: ENVI Routines

DT (optional)
Use this optional keyword to specify the data type of the slider values, using the
following IDL convention:

1 byte (8-bits)

2 integer (16-bits)

3 long integer (32-bits)

4 floating-point (32-bits)

5 double-precision floating point (64-bits)

6 complex (2x32-bits)

9 double -precision complex (2x64-bits)

12 unsigned integer (16-bits)

13 unsigned long integer (32-bits)

14 long 64-bit integer

15 unsigned long 64-bit integer.

FIELD (optional)
Use this optional keyword to set the number of decimal places used to format
numbers. This keyword has no effect unless the data type is 4 (float) or greater.

FLOOR (optional)
Use this optional keyword to set the minimum value allowed for input numbers. The
returned value will always be equal to or greater than this number, even if the slider is
positioned lower.

INCHES (optional)
Set this optional keyword to cause the slider to be annotated with " (the inch
symbol).

MAX
Use this keyword to specify an integer maximum for the slider. The value of MAX
will be multiplied by the value of SCALE to arrive at the actual maximum slider
value.

WIDGET_SSLIDER

ENVI Reference Guide

Chapter 2: ENVI Routines

755

MIN
Use this keyword to specify an integer minimum for the slider. The value of MIN will
be multiplied by the value of SCALE to arrive at the actual minimum slider value.

SCALE
Use this keyword to specify a multiplicative scale factor to be used in conjunction
with the MIN and MAX keywords. The default is 1.

TITLE
Use this keyword to specify a string that will appear as the title of the slider.

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.
For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag
name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

VALUE
Use this keyword to set an initial slider value. The SCALE factor is not applied.

XS (optional)
Use this optional keyword to provide a two-element array. The first element is the
slider size in pixels, and the second element is the text input widget size in characters.
The default array is [150, 7].

Widget Event
When the widget is not auto managed, widget events set event.result to the slider
value. This value is already scaled by the SCALE factor. The returned value is always
of type double and should be cast to the users selected data type.

ENVI Reference Guide

WIDGET_SSLIDER

756

Chapter 2: ENVI Routines

Example
Create a simple compound widget for selection of a value using a slider. Print out the
final slider location.
base = widget_auto_base(title=Simple Slider)
wg = widget_sslider(base, title=Samples, min=0, max=10, $
value=0, uvalue=slide, /auto)
result = auto_wid_mng(base)
if (result.accept eq 0) then return
print, Slider value, result.slide

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
WIDGET_PARAM

WIDGET_SSLIDER

ENVI Reference Guide

Chapter 2: ENVI Routines

757

WIDGET_STRING
WIDGET_STRING is a compound widget used to enter a string. The function returns
the base ID of the widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_STRING(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
ALL_EVENTS (optional)
Set this optional keyword to specify that the widget generate an event for all
supported events.

AUTO_MANAGE (optional)
Set this optional keyword to specify that the widget be managed by the ENVI
function AUTO_WID_MNG.

DEFAULT (optional)
Use this optional keyword to specify a default string.

PROMPT (optional)
Use this optional keyword to specify the prompt string to be used for the widget.

ENVI Reference Guide

WIDGET_STRING

758

Chapter 2: ENVI Routines

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.
For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag
name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

XSIZE (optional)
Use this optional keyword to specify the width of the widget, in characters.

Widget Event
When the widget is not auto managed, widget events set event.result to the
entered string.

Example
Create a simple compound widget to enter in a string value, and then print out the
entered string.
base = widget_auto_base(title=Edit String)
ws = widget_string(base, uvalue=str, /auto)
result = auto_wid_mng(base)
if (result.accept eq 0) then return
print, New String , result.str

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
WIDGET_PARAM

WIDGET_STRING

ENVI Reference Guide

Chapter 2: ENVI Routines

759

WIDGET_SUBSET
WIDGET_SUBSET is a compound widget used to specify image subsets. The
function returns the base ID of the widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_SUBSET(Base)

Arguments
Base
The widget ID of the base widget.

Keywords
AUTO_MANAGE (optional)
Set this optional keyword to specify that the widget be managed by the ENVI
function AUTO_WID_MNG.

DIMS
Use this keyword to specify a named variable that contains a five-element array
holding the initial data dimensions. The elements are defined as follows:

DIMS[0]: a pointer to the ROI (set to -1 if no ROI is selected).

DIMS[1]: the starting X coordinate.

DIMS[2]: the ending X coordinate.

DIMS[3]: the starting Y coordinate.

DIMS[4]: the ending Y coordinate.

FID
Use this keyword to specify the file ID of the file in use. The file ID is used to get the
file name and the number of samples and lines.

ENVI Reference Guide

WIDGET_SUBSET

760

Chapter 2: ENVI Routines

ROI (optional)
Set this optional keyword to allow ROI subsetting of a file. The ROI ID is returned as
the first elements in the DIMS array.

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.
For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag
name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

XS (optional)
Use this optional keyword to specify the X size in characters

Widget Event
When the widget is not auto managed, widget events set event.result to the
DIMS array.

Example
Create a simple compound widget for selecting image subsets. Print out the new dims
array.
envi_file_query, fid, ns=ns, nl=nl
dims = [-1, 0, ns-1, 0, nl-1]

base = widget_auto_base(title=Subset test)


ws = widget_subset(base, uvalue=subset, fid=fid,$
dims=dims, /auto)
result = auto_wid_mng(base)
if (result.accept eq 0) then return
print, New dims, result.subset

See Also
AUTO_WID_MNG
WIDGET_AUTO_BASE
ENVI_SELECT

WIDGET_SUBSET

ENVI Reference Guide

Chapter 2: ENVI Routines

761

WIDGET_TOGGLE
The WIDGET_TOGGLE compound widget is used to create arrow toggle selections.
The function returns the base ID of the widget.
Note
An interactive ENVI session is required to run this routine.

Syntax
Result = WIDGET_TOGGLE(Base)

Arguments
Base
The widget ID of the widget base.

Keywords
AUTO_MANAGE (optional)
Set this optional keyword to specify that the widget be managed by the ENVI
function AUTO_WID_MNG.

DEFAULT (optional)
Use this optional keyword to specify the list item that is selected by default.

LIST
Use this keyword to specify a string array of items in the selection list.

PROMPT (optional)
Use this optional keyword to specify the prompt string to be used for the widget.

UVALUE
Use this keyword to assign a user value to the widget. This value may be of any
data type and organization. The user value exists entirely for the convenience of the
programmer. The UVALUE can be retrieved by using WIDGET_CONTROL.

ENVI Reference Guide

WIDGET_TOGGLE

762

Chapter 2: ENVI Routines

For widgets managed by the ENVI function AUTO_WID_MNG, UVALUE is a tag


name in the returned anonymous structure. For user-managed widgets, UVALUE can
be set and used as desired. UVALUE must be set for all compound widgets.

XSIZE (optional)
Use this optional keyword to specify the width of the widget, in characters.

Example
Create a simple compound widget for displaying a toggle selection. Print out the final
toggle selection.
base = widget_auto_base(title=Toggle test)
list = [Item A, Item B, Item C]
sb = widget_base(base, /row)
wt = widget_toggle(sb, uvalue=toggle, list=list, /auto)
result = auto_wid_mng(base)
if (result.accept eq 0) then return
print, Toggle Selected, result.toggle

WIDGET_TOGGLE

ENVI Reference Guide

Index
Numerics
3D image cube
routine, 230

A
ADAPT_FILT_DOIT, 47
adaptive filtering
program, 47
adding
menu buttons, 236
AIRSAR
header information, 52
pedestal height, 54
phase image, 57

ENVI Reference Guide

polarization signatures, 60
scatter classification, 63
synthesize image, 67
AIRSAR_HEADER_DOIT, 52
AIRSAR_PED_HEIGHT_DOIT, 54
AIRSAR_PHASE_IMAGE_DOIT, 57
AIRSAR_POLSIG_DOIT, 60
AIRSAR_SCATTER_DOIT, 63
AIRSAR_SYNTH_DOIT, 67
annotation
user-defined, 498
area-based matching
program, 166
arguments, described, 15
ASCII
column data, 412
aspect corrections, 71

763

764

assigning
user-defined header values, 163
atmospheric correction, 491
AUTO_WID_MNG, 74
AVHRR
calibrating data, 176
computing geometry, 179
warping data, 182

B
bad lines
correction, 75
BAD_DATA_DOIT, 75
Band Math
program, 561
band ratios
program, 604
band selection, 610
BandMax
significant bands, 186
batch execution
apply lookup table (LUT), 546
available routines, 18
batch mode
exiting, 190
initializing, 192
buffer zone image, 197
building FFT filter, 304

C
calculating
polarization signatures, 653
statistics, 478
calibrating
AVHRR data, 176
empirical line, 155
image with Flat Field, 200
image with IARR, 200

Index

Landsat 7 data, 362


MSS data, 580
TIMS data, 687
calling sequence
functions, 15
procedures, 15
CATCH, 78
CEOS format SeaWiFS data, 434
CF_DOIT, 79
class statistics, 108
CLASS_CONFUSION_DOIT, 82
CLASS_CS_DOIT, 87
CLASS_DOIT, 91
CLASS_MAJORITY_DOIT, 102
CLASS_RULE_DOIT, 105
CLASS_STATS_DOIT, 108
classes
combining, 112
classification
calculate statistics, 108
classify rule images, 105
clump/seive, 87
computing confusion matrix, 82
create buffer zone image, 197
create image from regions of interest, 430
create segmentation image, 444
majority/minority analysis, 102
neural net, 378
overlays, 205
supervised, 91
classify rule images, 105
classifying
AIRSAR scattering, 63
closing
display group, 204
vector file, 269
clump and sieve classification, 87
collecting
endmember spectra, 208
color transforms
forward, 615

ENVI Reference Guide

765

HLS to RGB, 612


HSV to RGB, 612
inverse, 612
RGB to HLS, 615
RGB to HSV, 615
COM_CLASS_DOIT, 112
combining
classes, 112
compound widgets
ENVI_INFO_WID, 358
offsets, 203
WIDGET_MAP, 728
computing
AVHRR geometry, 179
confusion matrix, 82
sun angles, 211
configuration values, 311
continuum removal, 115
CONTINUUM_REMOVE_DOIT, 115
contrast stretch, 672
CONV_DOIT, 118
convert IDL array to ENVI image, 516
CONVERT_DOIT, 122
CONVERT_INPLACE_DOIT, 125
converting
emissivity, 158
file coordinates, 213
gridded points to raster, 349
interleave types, 122
interleave types in place, 125
LAS LIDAR data, 220
map projection, 215
projection coordinates, 225
VAX IEEE floating point, 707
convolution filtering
program, 118
coordinates
converting, 213
correcting
bad lines, 75
creating

ENVI Reference Guide

map projections, 370


new file from bands, 79
regions of interest, 228
CROSS_TRACK_CORRECTION_DOIT, 128
cross-track illumination, 128

D
dark region subtraction, 133
DARK_SUB_DOIT, 133
DECOR_DOIT, 136
decorrelation stretch, 136
deleting
regions of interest, 247
DEM
correct bad data, 139
DEM_BAD_DATA_DOIT, 139
DESKEW_DOIT, 142
deskewing MSS, 142
DESTRIPE_DOIT, 145
destriping image data, 145
DISP_GET_LOCATION, 148
DISP_GOTO, 150
DISP_OUT_IMG, 152
display group
closing, 204
displaying
grayscale or RGB, 251
image information, 321
numbers list, 315
pixel location, 148
X,Y plots, 400

E
edit multiple values, 722
ELINE_CAL_DOIT, 155
emissivity conversion, 158
EMITTANCE_CALC_DOIT, 158
empirical line calibration, 155

Index

766

endmember collection, 208


entering image data, 257
ENVI
library functions, 41
library routines reference, 33
list of routines, 18
program, 161
variable codes, 41
ENVI projection
structure, 403
update, 162
ENVI vector file
add record, 271
close, 269
DBF attribute file, 512
defining, 275
getting information, 283
new, 279
opening, 286
retrieving records, 288
shapefile format program, 290
ENVI_ADD_PROJECTION, 162
ENVI_ASSIGN_HEADER_VALUE, 163
ENVI_AUTO_TIE_POINTS_DOIT, 166
ENVI_AVHRR_CALIBRATE_DOIT, 176
ENVI_AVHRR_GEOMETRY_DOIT, 179
ENVI_AVHRR_WARP_DOIT, 182
ENVI_BANDMAX_SELECT_BANDS, 186
ENVI_BATCH_EXIT, 190
ENVI_BATCH_INIT, 192
ENVI_BATCH_STATUS_WINDOW, 194
ENVI_BUFFER_ZONE_DOIT, 197
ENVI_CAL_DOIT, 200
ENVI_CENTER, 203
ENVI_CLOSE_DISPLAY, 204
ENVI_CLOVER_DOIT, 205
ENVI_COLLECT_SPECTRA, 208
ENVI_COMPUTE_SUN_ANGLES, 211
ENVI_CONVERT_FILE_COORDINATES,
213

Index

ENVI_CONVERT_FILE_MAP_PROJECTIO
N, 215
ENVI_CONVERT_LIDAR_DATA_DOIT,
220
ENVI_CONVERT_PROJECTION_COORDI
NATES, 225
ENVI_CREATE_ROI, 228
ENVI_CUBE_3D_DOIT, 230
ENVI_DEFAULT_STRETCH_CREATE, 233
ENVI_DEFINE_MENU_BUTTON, 236
ENVI_DEFINE_ROI, 244
ENVI_DELETE_ROIS, 247
ENVI_DISP_QUERY, 248
ENVI_DISPLAY_BANDS, 251
ENVI_DOIT, 254
ENVI_ENTER_DATA, 257
ENVI_ENVISAT_GEOREF_DOIT, 265
ENVI_EVF_CLOSE, 269
ENVI_EVF_DEFINE_ADD_RECORD, 271
ENVI_EVF_DEFINE_CLOSE, 275
ENVI_EVF_DEFINE_INIT, 279
ENVI_EVF_INFO, 283
ENVI_EVF_OPEN, 286
ENVI_EVF_READ_RECORD, 288
ENVI_EVF_TO_SHAPEFILE, 290
ENVI_FILE_MNG, 292
ENVI_FILE_QUERY, 293
ENVI_FILE_TYPE, 301
ENVI_FILTER_DOIT, 304
ENVI_GEOREF_FROM_GLT_DOIT, 307
ENVI_GET_CONFIGURATION_VALUES,
311
ENVI_GET_DATA, 312
ENVI_GET_DISPLAY_NUMBERS, 315
ENVI_GET_FILE_IDS, 316
ENVI_GET_HEADER_VALUE, 317
ENVI_GET_IMAGE, 321
ENVI_GET_MAP_INFO, 323
ENVI_GET_PATH, 325
ENVI_GET_PROJECTION, 326
ENVI_GET_RGB_TRIPLETS, 328

ENVI Reference Guide

767

ENVI_GET_ROI, 330
ENVI_GET_ROI_DATA, 332
ENVI_GET_ROI_DIMS_PTR, 334
ENVI_GET_ROI_IDS, 335
ENVI_GET_ROI_INFORMATION, 337
ENVI_GET_SLICE, 339
ENVI_GET_STATISTICS, 341
ENVI_GET_TILE, 344
ENVI_GLT_DOIT, 346
ENVI_GRID_DOIT, 349
ENVI_GS_SHARPEN_DOIT, 353
ENVI_INFO_WID, 358
ENVI_INIT_TILE, 359
ENVI_IO_ERROR, 361
ENVI_L7_CPF, 362
ENVI_LAYER_STACKING_DOIT, 364
ENVI_MAP_INFO_CREATE, 370
ENVI_MASK_APPLY_DOIT, 375
ENVI_NEURAL_NET_DOIT, 378
ENVI_OPEN_DATA_FILE, 384
ENVI_OPEN_FILE, 390
ENVI_OUTPUT_TO_EXTERNAL_FORMA
T, 392
ENVI_PC_SHARPEN_DOIT, 395
ENVI_PICKFILE, 398
ENVI_PLOT_DATA, 400
ENVI_PROJ_CREATE, 403
ENVI_QUERY_VERSION, 407
ENVI_RADARSAT_GEOREF_DOIT, 408
ENVI_READ_COLS, 412
ENVI_REGISTER_DOIT, 414
ENVI_REPORT_ERROR, 420
ENVI_REPORT_INC, 422
ENVI_REPORT_INIT, 423
ENVI_REPORT_STAT, 425
ENVI_RESAMPLE_SPECTRA, 427
ENVI_RESTORE_ROIS, 429
ENVI_ROI_TO_IMAGE_DOIT, 430
ENVI_SAVE_ROIS, 433

ENVI Reference Guide

ENVI_SEAWIFS_GEOMETRY_DOIT, 434
ENVI_SEAWIFS_GEOREF_DOIT, 439
ENVI_SEGMENT_DOIT, 444
ENVI_SELECT, 447
ENVI_SENSOR_TYPE, 452
ENVI_SET_INHERITANCE, 455
ENVI_SETUP_HEAD, 458
ENVI_SMACC_DOIT, 468
ENVI_SPECTRAL_RESAMPLING_DOIT,
474
ENVI_STATS_DOIT, 478
ENVI_SUM_DATA_DOIT, 484
ENVI_SYNTHETIC_COLOR_DOIT, 488
ENVI_THERMAL_CORRECT_DOIT, 491
ENVI_TILE_DONE, 494
ENVI_TOGGLE_CATCH, 495
ENVI_TRANSLATE_PROJECTION_NAME
, 496
ENVI_TRANSLATE_PROJECTION_UNITS
, 497
ENVI_USER_DEFINED_ANNOTATION,
498
ENVI_VEG_INDEX_AVAILABLE_INDICE
S, 506
ENVI_VEG_INDEX_DOIT, 509
ENVI_WRITE_DBF_FILE, 512
ENVI_WRITE_ENVI_FILE, 516
ENVI_WRITE_FILE_HEADER, 526
ENVI_WRITE_STATISTICS, 528
error
catching, 495
input/output, 593
reporting, 420
event handling, 74
exceptions and errors handling, 78
exiting
batch mode, 190
exporting
ENVI_EVF_TO_SHAPEFILE, 290

Index

768

F
feature-based matching
program, 166
FFT
forward transform, 531
inverse transform, 534
FFT filtering
building, 304
filter definition, 304
inverse, 534
FFT_DOIT, 531
FFT_INV_DOIT, 534
file
choosing filenames, 398
getting file type description, 301
ID, 316
management, 292
selection and subsetting, 447
filenames, 398
filtering
adaptive, 47
convolutions, 118
matched, 553
Mixture Tuned Matched Filtering, 557
morphological, 570
formal parameters, 16
function calling sequence, 15

G
gain and offset user function, 538
GAINOFF_DOIT, 538
Geographic Lookup Tables (GLT), 307
building, 346
georeferenced image
building multiband file from, 364
displaying map information, 323
mosaicking, 574
georeferencing
AATSR data, 265

Index

ASAR data, 265


ENVISAT data, 265
image from GLT files, 307
MERIS data, 265
RADARSAT, 408
SeaWiFS data, 439
get user-defined header values, 317
Gram-Schmidt Spectral Sharpening, 353

H
HANDLE_VALUE, 544
handles, 544
HDF format SeaWiFS data, 434
header
file
information, 458
writing, 526
user-defined value
assigning, 163
getting, 317
preserving changes, 526
HIST_EXPORT_DOIT, 546
histogram
exporting, 546

I
image
georeferencing, 370
warping data, 414
image-to-image registration, 414
image-to-map registration, 414
inheritance structure, 455
initializing
batch mode, 192
input error handling, 593
installation path, 325
inverse MNF transform, 568

ENVI Reference Guide

769

K
keywords
described, 16
meaning of slash character, 16
setting, 16

L
Landsat
deskew MSS, 142
LAS LIDAR format
converting data, 220
library
functions, 41
routines, 33

MNF_DOIT, 564
MNF_INV_DOIT, 568
MORPH_DOIT, 570
morphological filtering
program, 570
MOSAIC_DOIT, 574
mosaicking images
program, 574
moving
pixel location, 150
MSS aspect ratio, 71
MSS calibration, 580
MSS deskew, 142
MSSCAL_DOIT, 580
multilook SIR-C data, 641
Munsell to RGB, 584
MUNSELL_DOIT, 584
MUNSELL_INV_DOIT, 587

M
MAGIC_MEM_CHECK, 551
majority analysis, 102
map display information, 323
map projections
converting, 215
creating, 370
masking program, 375
MATCH_FILTER_DOIT, 553
MATCH_FILTER_MT_DOIT, 557
matched filtering
mixture tuned program, 557
program, 553
MATH_DOIT, 561
memory cache clear, 551
menu buttons, 236
minority analysis, 102
Mixture Tuned Matched Filtering
program, 557
MNF transform
program, 564
MNF transforn
inverse program, 568
ENVI Reference Guide

N
named variables
arguments, 15
keywords, 16
NDVI_DOIT, 590
neural net classification, 378
Normalized Difference Vegetation Index, 590

O
ON_IOERROR, 593
opening
data file, 384
ENVI file, 390
output
creating file from ABL bands, 79
error handling, 593
external format, 392
image using lookup table, 546
overlay classes, 205

Index

770

PC Spectral Sharpening, 395


PC_ROTATE, 594
pedestal height image
AIRSAR program, 54
SIR-C, 645
phase image
AIRSAR program, 57
SIR-C, 649
pixel
display location, 148
move location, 150
Pixel Purity Index (PPI), 598
plot display, 400
pointers and handles, 544
polarization signatures
AIRSAR program, 60
SIR-C, 653
positional parameters, 15
PostScript output, 152
PPI_DOIT, 598
principal components
PC Spectral Sharpening, 395
program, 594
rotating, 594
procedure calling sequence, 15
processing
status report, 423
status update, 425
programming in ENVI
routines, 18
projection information, 326

radar incidence angle image, 601


RADAR_INC_ANGLE_DOIT, 601
RADARSAT
georeferencing, 408
raster to vector program, 628
RATIO_DOIT, 604
reading
ASCII column data, 412
receiver operating characteristic curves, 618
regions of interest
creating, 228
defining, 244
deleting, 247
DIMS pointer value, 334
getting associated data, 332
getting IDs, 335
getting point addresses, 330
getting ROI information, 337
restoring saved, 429
saving, 433
threshold, 622
registration
image-to-image, 414
image-to-map, 414
removing
bad data, 75
reporting
errors, 420
widgets, 358
reporting input/output processing errors, 361
resampling
images spectrally, 474
spectra, 427
spectral libraries, 474
RESIZE_DOIT, 607
resizing
images, 607
restoring
base ENVI save files, 161
saved regions of interest, 429

Q
query
display information, 248
ENVI version, 407
header file information, 293

Index

ENVI Reference Guide

771

retrieving
data from ABL, 312
vector records, 288
RGB to Munsell, 587
RGB triplets, 328
RGB_GET_BANDS, 610
RGB_ITRANS_DOIT, 612
RGB_TRANS_DOIT, 615
ROC curves, 618
ROC_CURVE_DOIT, 618
ROI_THRESH_DOIT, 622
rotate images, 625
rotate/flip data, 625
ROTATE_DOIT, 625
routines
interface for processing routines, 254
list of available, 18
RTV_DOIT, 628

S
SAT_STRETCH_DOIT, 631
saturation stretch, 631
saving
shapefile program, 290
SeaWiFS data, 434
segmentation, 444
sensor type values, 452
setting keywords, 16
Shapefile
ENVI_EVF_TO_SHAPEFILE, 290
SHARPEN_DOIT, 634
sharpening program, 634
SIR-C
header information, 638
multilook, 641
pedestal height, 645
phase image, 649
polarization signatures, 653
synthesize images, 657

ENVI Reference Guide

SIRC_HEADER_DOIT, 638
SIRC_MULTILOOK_DOIT, 641
SIRC_PED_HEIGHT_DOIT, 645
SIRC_PHASE_IMAGE_DOIT, 649
SIRC_POLSIG_DOIT, 653
SIRC_SYNTH_DOIT, 657
slant to ground range, 664
slash character, 16
SLICE_DOIT, 662
SLT2GND_DOIT, 664
SMACC
processing program, 468
spectra
resampling, 427
Spectral Feature Fitting
program, 668
spectral sharpening
Gram-Schmidt, 353
Principal Components, 395
spectral slice, 339, 662
spectral unmixing, 703
SPECTRAL_FEATURE_DOIT, 668
statistics
calculate parameters, 484
calculating, 478
reading data, 341
writing to file, 528
status of batch display, 194
stretch
contrast (file-to-file), 672
default structure, 233
STRETCH_DOIT, 672
sum data bands, 484
supervised classification
program, 91
synthesizing
JPL AIRSAR data, 67
SIR-C images, 657
synthetic color image, 488

Index

772

TASCAP_DOIT, 676
Tasseled Cap transform, 676
texture filters
co-occurrence, 679
texture measure, 683
texture measure, 683
TEXTURE_COOCCUR_DOIT, 679
TEXTURE_STATS_DOIT, 683
thermal infrared data correction, 491
threshold ROIs, 622
tie points
program, 166
tile data, 344
tile data initialization, 359
tile processing completed, 494
tiled processing increments, 422
TIMS_CAL_DOIT, 687
TM calibration, 690
TMCAL_DOIT, 690
TOPO_DOIT, 694
TOPO_FEATURE_DOIT, 698
topographic features, 698
topographic modeling, 694
translating
projection name, 496
projection units, 497

variables
named in keywords, 16
named, in arguments, 15
VAX_IEEE_DOIT, 707
vegetation analysis
ENVI_VEG_INDEX_AVAILABLE_INDI
CES, 506
ENVI_VEG_INDEX_DOIT, 509

U
UNMIX_DOIT, 703
unmixing, 703
updating
projections, 162
user functions
ENVI compound widgets, 728
ENVI subroutines, 312
user-defined header values
getting, 317
preserving changes, 526

Index

W
warping
AVHRR data, 182
image data, 414
widget
arrow toggle, 761
auto-based, 709
base, 711
controlling, 716
creating a menu, 730
creating lists, 750
displaying scroll bar labels, 748
editing multiple list values, 722
entering a parameter, 740
entering a string, 757
input/edit map coordinates, 728
modifying RGB values, 746
pulldown menu, 744
reporting, 358
selecting multiple items, 733
selecting output file, 738
selecting output filename, 736
setting slider values, 753
specifying image subsets, 759
specifying latitude and longitude values, 726
WIDGET_AUTO_BASE, 709
WIDGET_BASE, 711
WIDGET_CONTROL, 716
WIDGET_EDIT, 722

ENVI Reference Guide

773

WIDGET_GEO, 726
WIDGET_MAP, 728
WIDGET_MENU, 730
WIDGET_MULTI, 733
WIDGET_OUTF, 736
WIDGET_OUTFM, 738
WIDGET_PARAM, 740
WIDGET_PMENU, 744
WIDGET_RGB, 746
WIDGET_SLABEL, 748
WIDGET_SLIST, 750

ENVI Reference Guide

WIDGET_SSLIDER, 753
WIDGET_STRING, 757
WIDGET_SUBSET, 759
WIDGET_TOGGLE, 761
widgets
centering offsets, 203
event handling, 74
writing
ENVI file, 516
ENVI_EVF_TO_SHAPEFILE, 290
header file, 526

Index

774

Index

ENVI Reference Guide

You might also like