X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 26 Aug 2015 10:22 AM by  anon
Batch converting .sta to .txt files
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
26 Aug 2015 10:22 AM
    I have a couple hundred .sta files generated using ROI's, and I would like to convert all of them to text files. I know I can create text files of stats based on individual ROI's in the GUI but it is rather time consuming. I also know you can save all stats from individual ROI's into just 1 text file, but the way ENVI outputs it is incredibly messy and the individual files are easier to work with. Is there a way to convert .sta to .txt or .csv in IDL? EDIT: I am trying to use something like this code, but I know there are probably numerous errors in it. I am pretty new to IDL but I have put comments in for what I am attempting to do with the lines of code: pro stats_to_text ;image to calculate stats on for each roi which is a stacked image of 80 bands. I want stats for all 80 bands envi_open_file, 'F:\Sheyenne\Atmospherically Corrected Landsat\Indices\Main\SATVI\SATVI_stacked' ;folder containing all rois to calculate stats on cd,'F:\Sheyenne\ROI\Allotments' files=file_search('*roi',count=count,/fold_case) envi_restore_rois,name roi_ids=envi_get_roi_ids(fid=fid,roi_names=roi_names) npts=1100 pts=fltarr(5,npts) roi_dims=envi_get_roi_dims_ptr(roi_ids[0]) dims=[roi_dims,0,0,0,0] ;output filename is same as input but add .txt to end out_name=file_basename(filename, '.dat') + '.txt' ;calculate the stats envi_doit, 'envi_stats_doit', fid=fid, pos=pos, $ dims=dims, comp_flag=1, mean=mean, dmin=dmin, dmax=dmax, STDV=STDV, REP_Name=out_name end the the program compiles but doesn't seem to do anything

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    26 Aug 2015 11:37 AM
    You can get the text file using ENVI_STATS_DOIT and the REP_NAME keyword. If you want one ROI at a time, then feed one ROI into the DIMS (ROIs are the first element of the DIMS for this). For example: roi_ids = envi_get_ro_ids() roi_dims = envi_get_roi_dims_ptr(roi_ids[0]) dims = [roi_dims, 0, 0, 0, 0]
    You are not authorized to post a reply.