I would like to use ENVI_OUTPUT_TO_EXTERNAL_FORMAT to save some ENVI files into various formats (ESRI GRID and tiff). See below for the code I am using. I keep getting an error on my endfor and end, not sure what I am doing. Thanks
pro outputtoexternalfile2
compile_opt strictarr
ENVI, /RESTORE_BASE_SAVE_FILES
;set up path to input and output files
input_path = 'E:\test\'
; search for data files in the specified directory
files = FILE_SEARCH(input_path+'*_NBR', 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=refl_fid
if (refl_fid eq -1) then begin
envi_batch_exit
return
endif
ENVI_FILE_QUERY, refl_fid, ns=ns, nl=nl, nb=nb, data_type=data_type, fname=filename
pos=lindgen(nb)
dims=[-1L,0, ns-1, 0, nl-1]
out_name = filename + '_test'
ENVI_OUTPUT_TO_EXTERNAL_FORMAT, dims = dims, /TIFF, FID=refl_FID, pos=pos, out_name=out_name $
endfor
end
|