The code below works for one equation using math_doit. How could I do multiple equations on multiple images in a folder. Fow example the below code calculates NBR from (b9-b24)/(b9+b24) and outputs a filename with filename_NBR. How could I also get NDVI from (b9-b5)/(b9-b5) and have it output as filename_NDVI.
Thanks
pro bandmath_NBR
compile_opt idl2
input_path = 'E:\FinalProcessing\GrassValley_Slide\georef_atcoroutput\'
cd, 'E:\FinalProcessing\GrassValley_Slide\burn_indices\'
files=FILE_SEARCH(input_path+'*_atm.bsq_georef', count=count)
IF(count EQ 0)THEN BEGIN
PrintF, 'No files were found to process'
ENDIF
;open file
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 calculation EVI
t_fid=[fid,fid]
pos = [9, 24]-1
exp = '(b9-b24)/(b9+b24)'
;set the output filenames by stripping out the base name and appending 'nbr.img'
out_name = file_basename(filename, '_atm.bsq_georef')+'_NBR'
;call the doit
envi_doit,'math_doit',$
fid=t_fid, pos=pos, dims=dims,$
exp=exp, out_name=out_name, $
r_fid=r_fid
print, 'done'
endfor
end
|