The answer you replied is quite helpful, likewise, dear Pete, I also need your help in this same question, basically i don't want to pick files when it asks (using 'ENVI_PICKFILE'), because i have to process several images, and it seems tedious to me, therefore i made an attempt to do this all automatically, but the error occurs, and to tell you the truth the program i have made is also kind of tedious, do you know how to run it in loop? i want to save first four files as envi standard, then next four, then next four, and so on
pro Layer_Stack
compile_opt idl2
;
; First restore all the base save files.
;
envi, /restore_base_save_files
ENVI_INIT, /batch_mode
;
; Open the input file
;
CD, 'D:\test2\Layer stack\LT51510372009253KHC00\'
file = FILE_SEARCH('*.TIF')
ENVI_OPEN_FILE, file(0), r_fid=fid
ENVI_FILE_QUERY, fid, dims=dims, nb=nb, geo_points=geo_points, nl=nl, ns=ns
ENVI_OPEN_FILE, file(1), r_fid=fid
ENVI_FILE_QUERY, fid, dims=dims, nb=nb, geo_points=geo_points, nl=nl, ns=ns
ENVI_OPEN_FILE, file(2), r_fid=fid
ENVI_FILE_QUERY, fid, dims=dims, nb=nb, geo_points=geo_points, nl=nl, ns=ns
ENVI_OPEN_FILE, file(3), r_fid=fid
ENVI_FILE_QUERY, fid, dims=dims, nb=nb, geo_points=geo_points, nl=nl, ns=ns
fid=[fid1,fid2,fid3,fid4]
pos=[0,0,0,0]
; Create the new ENVI file
envi_doit, 'cf_doit', fid=fid, pos=pos, dims=dims, $
out_name='layer_stack1.tif', r_fid=r_fid
CD, 'D:\test2\Layer stack\LT51510372009253KHC00\'
file = FILE_SEARCH('*.TIF')
ENVI_OPEN_FILE, file(4), r_fid=fid
ENVI_FILE_QUERY, fid, dims=dims, nb=nb, geo_points=geo_points, nl=nl, ns=ns
ENVI_OPEN_FILE, file(5), r_fid=fid
ENVI_FILE_QUERY, fid, dims=dims, nb=nb, geo_points=geo_points, nl=nl, ns=ns
ENVI_OPEN_FILE, file(6), r_fid=fid
ENVI_FILE_QUERY, fid, dims=dims, nb=nb, geo_points=geo_points, nl=nl, ns=ns
ENVI_OPEN_FILE, file(7), r_fid=fid
ENVI_FILE_QUERY, fid, dims=dims, nb=nb, geo_points=geo_points, nl=nl, ns=ns
fid=[fid1,fid2,fid3,fid4]
pos=[0,0,0,0]
; Create the new ENVI file
envi_doit, 'cf_doit', fid=fid, pos=pos, dims=dims, $
out_name='layer_stack1.tif', r_fid=r_fid
; Exit ENVI
;
envi_batch_exit
end
|