If you still have access to ENVI, you can use the batch routine 'NDVI_DOIT' to calculate NDVI for several images. For other indices, you would need to use MATH_DOIT. You need to set up a loop to work through each file. There is an example of both the NDVI and MATH DOIT routines in the ENVI Help. To process multiple files, you need to loop through each input set of files. The basics include searching a folder for files to process, then feed each file into the routine. For example:
pro ndvi_batch
compile_opt idl2
;set up path to input and output files
input_path = 'c:\myInputData\'
;change to output directory where I want the processed files to be placed
cd, 'C:\myProcessedData\'
; search for data files in the specified directory
files = FILE_SEARCH(input_path + '*.dat', count=count)
IF (count EQ 0) THEN BEGIN
PrintF, 'No files were found to process'
ENDIF
for i=0, count-1 do begin
envi_open_file, files[i], r_fid=fid
if (fid eq -1) then begin
envi_batch_exit
return
endif
envi_file_query, fid, dims=dims, ns=ns, nl=nl, fname=filename
;set pos array for calculating NDVI
pos = [4,3] - 1
;set the output file names by stripping out the base name and appending 'ndvi.img'
out_name = file_basename(filename, '.dat') + '_ndvi.img'
;call the doit
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
endfor
end
BAND_MATH is a little more complicated when setting up the FID and POS but the idea is the same.
|