Hi,
I'm very new in IDL.
I want to calculate NDVI indice for a lot of images with got from private company. I found in this forum a pro code and i tryed to adapt it but it not working. Please check and tell me what is wrong.
pro ndvi_batch
compile_opt idl2
;set up path to input and output files
;input_path = 'X:\JEdi_D2\GrassService\Siguldas_nov\Process\140708\112717_2'
;change to output directory where I want the processed files to be placed
cd, 'X:\JEdi_D2\GrassService\Siguldas_nov\Process\140708\112717'
; search for data files in the specified directory
files = FILE_SEARCH('X:\JEdi_D2\GrassService\Siguldas_nov\Process\140708\112717\CASI_2014_07_08_112717_g.pix', 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 = [21,10] - 1
;set the output file names by stripping out the base name and appending 'ndvi.img'
out_name = file_basename(filename,'.dat')+'_NDVI.dat'
;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
IDL> ndvi_batch
% Compiled module: NDVI_BATCH.
% Expression must be a scalar or 1 element array in this context: .
% Execution halted at: NDVI_BATCH 18 X:\JEdi_D2\!IDL_darbs\ndvi_batch.pro
% $MAIN$
|