Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
It should be fine to use the ENVI_DOIT, 'CF_DOIT' routine, since this is the routine used when you use the New File Builder (File>Save File As>ENVI Standard) which allows you to create a new multiband file from several single band files (That must be all the same size). Just remember that you must pass an array of band positions (pos) corresponding to the bands you want to use, and an array of the corresponding File ID's (fid). In your case, pos will be an array of zeros corresponding to the number of single band files. A simple example would be something like: ; Open the files envi_open_file, 'Band1.img', r_fid=fid1 envi_open_file, 'Band2.img', r_fid=fid2 envi_open_file, 'Band3.img', r_fid=fid3 ; Query one of the files to get the dimensions ; Note ALL the files MUST be the same size envi_file_query, fid1, ns=ns, nl=nl dims = [-1, 0, ns-1, 0, nl-1] ; Build the fid and pos arrays fid=[fid1,fid2,fid3] pos=[0,0,0] ; Create the new ENVI file envi_doit, 'cf_doit', fid=fid, pos=pos, dims=dims, $ out_name="New_File.img", r_fid=r_fid end Cheers, Peter "St�phane SAUX PICART" <stephane.saux-picart@cesbio.cnes.fr> wrote in message news:d95ff3c7.0303260201.46b3d2bf@posting.google.com... > I am trying to use the ENVI routine: ENVI_DOIT, 'CF_DOIT' > I have several files containing only one band and I would like to save > them in a single file containing several bands. > Is it possible to use that routine? > Are there other ways to compute that? > > Thank you > > St�phane SAUX PICART
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