ENVI

NDVI_DOIT

NDVI_DOIT

Use this procedure to create a normalized difference vegetation index (NDVI).

Example


; Start ENVI
e = ENVI()
 
; Open a data file
File = Filepath('qb_boulder_msi', Root_Dir = e.Root_Dir, $
   Subdir = ['data'])
Raster = e.OpenRaster(File)
 
; Determine an output file
OutFile = e.GetTemporaryFilename()
 
; Return a file ID
fid = ENVIRasterToFID(Raster)
 
; Compute NDVI on this QuickBird scene
ENVI_File_Query, fid, DIMS=dims
ENVI_Doit, 'NDVI_Doit', $
   FID = fid, $
   DIMS = dims, $
   POS = [3,2], $
   /CHECK, $
   OUT_DT = 4, $
   OUT_NAME = OutFile

Syntax


ENVI_DOIT, 'NDVI_DOIT', /CHECK, DIMS=array, FID=file ID, /IN_MEMORY, O_MAX=value, O_MIN=value, OUT_BNAME=string array, OUT_DT={1 | 4}, OUT_NAME=string, POS=array, R_FID=variable

Keywords


CHECK

Set this keyword to check for divide-by-zero errors. These errors are set to 0.

DIMS

The “dimensions” keyword is a five-element array of long integers that defines the spatial subset (of a file or array) to use for processing. Nearly every time you specify the keyword FID, you must also specify the spatial subset of the corresponding file (even if the entire file, with no spatial subsetting, is to be processed).

  • DIMS[0]: A pointer to an open ROI; use only in cases where ROIs define the spatial subset. Otherwise, set to -1L.
  • DIMS[1]: The starting sample number. The first x pixel is 0.
  • DIMS[2]: The ending sample number
  • DIMS[3]: The starting line number. The first y pixel is 0.
  • DIMS[4]: The ending line number

To process an entire file (with no spatial subsetting), define DIMS as shown in the following code example. This example assumes you have already opened a file using ENVI_SELECT or ENVI_PICKFILE:

  envi_file_query, fid, dims=dims

FID

The file ID (FID) is a long-integer scalar with a value greater than 0. An invalid FID has a value of -1. The FID is provided as a named variable by any routine used to open or select a file. Often, the FID is returned from the keyword R_FID in the ENVIRasterToFID routine. Files are processed by referring to their FIDs. If you work directly with the file in IDL, the FID is not equivalent to a logical unit number (LUN).

IN_MEMORY

Set this keyword to specify that output should be stored in memory. If you do not set IN_MEMORY, output will be stored on disk and you must specify OUT_NAME (see below).

O_MAX

Use this keyword to specify the output data maximum. Only use this keyword when OUT_DT=1 (byte).

O_MIN

Use this keyword to specify the output data minimum. Only use this keyword when OUT_DT=1 (byte).

OUT_BNAME

Use this keyword to specify a string array of output band names.

OUT_DT

This keyword indicates the IDL data type of the output data. Set the keyword to 1 for byte data and 4 for floating-point data.

OUT_NAME

Use this keyword to specify a string with the output filename for the resulting data. If you set the keyword IN_MEMORY, you do not need to specify OUT_NAME.

POS

Use this keyword to specify an array of zero-based, two-band positions. The following table lists examples for different sensors.

Data Type

Band Numbers (IR, Red)

POS value

Landsat TM

(4, 3)

[3,2]

Landsat MSS

(7, 5)

[6,4]

AVHRR

(2, 1)

[1,0]

SPOT XS

(3, 2)

[2,1]

AVIRIS

(51, 29)

[50,28]

R_FID

ENVI Classic library routines that result in new images also have an R_FID, or “returned FID.” This is simply a named variable containing the file ID to access the processed data. Specifying this keyword saves you the step of opening the new file from disk.

Notes


This page has no user notes yet. Be the first one!


This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However, it may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
© 2014 Exelis Visual Information Solutions