X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 02 Nov 2016 04:50 PM by  anon
Extract Min and Max Data from ALL Raster Cells in Layer Stack
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
02 Nov 2016 04:50 PM
    Hey ENVI Users, I'm looking to extract some crop phenology information from a single-year NDVI layer stack. I need to get the minimum and maximum values for EVERY cell, across 23 layers (the growing season) within my study area. Anyone have an idea how to do this? The study area is roughly 2600x1400 pixels. Thanks, Andy

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    03 Nov 2016 05:42 AM
    There is no tool in ENVI to do this but a function could be written in IDL. I created a program many years ago that would run in ENVI Classic but it should still work in ENVI 5.x. You could try the below: pro max_min_value, ev compile_opt IDL2 ;select input file and gather information envi_select, fid=fid, dims=dims, pos=pos, title = 'Select an input file' if (fid eq -1) then return envi_file_query, fid, ns=ns, nl=nl, nb=nb, data_type=dt, interleave=interleave, $ xstart=xstart,ystart=ystart, fname=fname, dims=dims inherit = envi_set_inheritance(fid, dims, /spatial) ;set the output name base = widget_auto_base(title='Output file name') wo = widget_outf(base, uvalue='outf', /auto) result = auto_wid_mng(base) if (result.accept eq 0) then return out_name=result.outf ;open a file to write and initialize tiling openw, unit, out_name, /get_lun tile_id = envi_init_tile(fid, pos, num_tiles=num_tiles, $ interleave=(interleave > 1), xs=dims[1], xe=dims[2], $ ys=dims[3], ye=dims[4]) envi_report_init, ['Input file: '+fname,'Output file: '+out_name], $ title='Calculating Min/Max values...', base=base envi_report_inc, base, num_tiles ;start process tiling for i=0L, num_tiles-1 do begin envi_report_stat, base, i, num_tiles, cancel=cancel if cancel eq 1 then begin envi_report_init, base=base, /finish return endif data = envi_get_tile(tile_id, i) maxdata = max(data, dimension=2, min=mindata) maxdata=reform(maxdata, ns, 1, /overwrite) mindata=reform(mindata, ns, 1, /overwrite) writeu, unit, [[maxdata], [mindata]] endfor envi_report_init, base=base, /finish free_lun, unit envi_tile_done, tile_id ;create ENVI header for output envi_setup_head, fname=out_name, ns=ns, nl=nl, nb=2, $ data_type=dt, offset=0, interleave=1, /write, /open, $ xstart=xstart+dims[1], ystart=ystart+dims[3], $ bnames=['Max value', 'Min value'], inherit=inherit envi_tile_done, tile_id end
    You are not authorized to post a reply.