X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 12 Sep 2011 11:16 AM by  anon
subsetting landsat image from an EVF or ROI file programmatically
 5 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
12 Sep 2011 11:16 AM
    Hi folks - It seems there ought to be an easy way to do the task I need to do in programming space. I want to write some code that can read in a series of Landsat images and subset them to an .evf file and save them subsetted. There does not appear to be an ENVI_DOIT sort of command that can do this, am I correct? What is the easiest way to program what I want to do? thank you, Cyndy

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    12 Sep 2011 02:52 PM
    There is an undocumented way to do this. With undocumented code, we cannot guarantee it will function the same way in the future but it seems like these routines have not changed in a while. Here is an example: pro subset_by_evf compile_opt idl2 ;select input file to subset fname = 'C:\Program Files\ITT\IDL70\products\envi45\data\world_dem' envi_open_file, fname, r_fid=fid if (fid[0] eq -1) then return envi_file_query, fid, bnames=bnames, sname=sname ;open vector file to use for subset and get id evf_fname = 'C:\Program Files\ITT\IDL70\products\envi45\data\vector\states_.evf' ;make sure envi vector routine is available envi_check_save, /vector ;open the vector and get its ID evf_open, evf_fname, vec=vec, /no_warning evf_id = vec.id ;compute the spatial boundary based on the evf using ROI routines (undocumented routine) - this will provide the DIMS to use to subset roi_ids = envi_get_roi_ids(fid=fid, /include_evfs) envi_roi_compute_spatial_boundry, roi_ids, dims, fid=fid ;resize the original image by the new dimensions envi_doit, 'resize_doit', fid=fid, dims=dims, pos=pos, $ rfact=[1.,1.], /in_memory, r_fid=sub_fid envi_file_query, sub_fid, ns=ns, nl=nl, dims=dims ;generate a mask from the evf (undocumented routine) - you need to mask areas outside of EVF boundaries if the EVF is not a rectangle ; this is the same as using Basic Tools ->Subset data via ROIs and masking the outside of the ROI/EVF boundary envi_mask_doit, evf_id=evf_id, evf_fid=sub_fid, ns=ns, nl=nl, and_or=0, $ /inside, /in_memory, r_fid=m_fid ;apply the mask to the subset image out_name=sname+'_subset' envi_mask_apply_doit, fid=sub_fid, pos=pos, dims=dims, m_fid=m_fid, m_pos=0l, $ value=-9999, out_bname=bnames, out_name=out_name ;close in memory files envi_file_mng, id=m_fid, /remove envi_file_mng, id=sub_fid, /remove envi_evf_close, evf_id end

    Deleted User



    New Member


    Posts:
    New Member


    --
    13 Sep 2011 10:14 AM
    This is terrific; I can do exactly what I need to do, now. Thank you, MariM very much!

    Deleted User



    New Member


    Posts:24
    New Member


    --
    17 Mar 2015 04:41 AM
    Hi Mari, How can I put an option to 'mask' or 'not to mask' in the outside of ROI (like subset in ENVI). Please note: I am using the lines given below to extract the data within ROI and masking the data outside ROIwith -9999. Please suggest me what modification is required in these lines sothat even outside the ROI it should not mask the data with -9999 but keep theactual data like inside ROI in order to make ROI data as rectangular instead ofas shape file polygon. I would appreciate your kind cooperation. envi_mask_doit, evf_id=evf_id, evf_fid=sub_fid, ns=ns, nl=nl, and_or=0, $ /inside,/in_memory, r_fid=m_fid ;apply the maskto the subset image envi_mask_apply_doit, fid=sub_fid, pos=pos, dims=dims, m_fid=m_fid,m_pos=0l, $ value=-9999,out_bname=bnames,out_name=file_out

    Deleted User



    New Member


    Posts:
    New Member


    --
    17 Mar 2015 05:47 PM
    To opt to 'mask' or 'not to mask' in the outside of ROI, you can use the keyword INSIDE with envi_mask_doit. Setting the INSIDE=0 in your code will apply the inverse mask. -Xiaoying Exelis VIS

    Deleted User



    New Member


    Posts:
    New Member


    --
    18 Mar 2015 12:59 PM
    You are not authorized to post a reply.