登録ログイン     
en-USfr-FRja-JP
 
Loading
Article ID: 4572        Category: ENVI
  How to call ENVI_LAYER_STACKING_DOIT with multiple files and bands in batch mode
Published on 04/13/2010
   

This Help Article provides an example of how to call ENVI_LAYER_STACKING_DOIT in batch mode. It provides a method for setting a directory and finding multiple files for stacking, then setting up the FID, POS, and DIMS arrays for any number of input files.

Users should change the 'CD' command to find the appropriate directory on their system and set the FILE_SEARCH file type (in this example, it is '.tif') to whatever is appropriate for their data. The FID, POS, and DIMS arrays are set up according to the order the files are found using FILE_SEARCH. Users will need to adjust these arrays if they need the files stacked in an alternate order.

pro envi_layer_stacking_doit_multi_file
compile_opt idl2

;first restore all the base save files and initialize batch.
envi, /restore_base_save_files
envi_batch_init, log_file='batch.txt'

;go to directory with several files
;this example stacks a set of .TIF files
cd, 'mydir'
files = file_search('*.tif', count=count, /fold_case)

;open and gather file information in arrays
in_fid=lonarr(count)
in_nb=lonarr(count)
in_dims=lonarr(5, count)
in_dt=lonarr(count)

for i=0L, count-1 do begin
envi_open_file, files[i], r_fid=r_fid
if (r_fid eq -1) then begin
envi_batch_exit
return
endif

envi_file_query, r_fid, ns=ns, nl=nl, nb=nb, dims=dims, data_type=dt
in_fid[i]=r_fid
in_nb[i]=nb
in_dims[*,i]=dims
in_dt[i]=dt
endfor

;set up output fid, pos, and dims arrays
out_fid = replicate(in_fid[0], in_nb[0])
for i=1, count-1 do out_fid = [out_fid, replicate(in_fid[i], in_nb[i])]

out_pos = lindgen(in_nb[0])
for i = 1, count-1 do out_pos = [out_pos, lindgen(in_nb[i])]

rep_dims = (intarr(in_nb[0])+1) # in_dims[*,0]
for i = 1, count-1 do $
rep_dims = [rep_dims, (intarr(in_nb[i]) + 1) # in_dims[*,i]]
out_dims = transpose(rep_dims)

;set the output projection and pixel size from the first file.
;save the result to disk and use max data type
out_proj = envi_get_projection(fid=in_fid[0], pixel_size=out_ps)
out_dt = max(in_dt)
out_name = 'stacked_layers.dat'

;call the layer stacking routine. Do not set the exclusive keyword allow for an
;inclusive result. Use nearest neighbor for the interpolation method.

envi_doit, 'envi_layer_stacking_doit', fid=out_fid, pos=out_pos, dims=out_dims, $
out_dt=out_dt, out_name=out_name, interp=0, out_ps=out_ps, $
out_proj=out_proj, r_fid=r_fid

;exit ENVI
envi_batch_exit

end
Printer friendly format:  print



Rating: rating

  Comments

There is no comment. To be the first to make a comment...

Your Name
Email
Website
Title
Comment
CAPTCHA image
Enter the code
 Like Us.
 Follow Us.
 Watch Us.
Home  | |   Site Map
Permissions/Legal   © 2011 Exelis Visual Information Solutions