X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



7272 Rate this article:
3.0

How to call ENVI_LAYER_STACKING_DOIT with multiple files and bands in batch mode

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

Review on 12/31/2013 MM

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »