X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 07 Nov 2014 02:34 PM by  anon
Data from ROI to an array (and then to a Text File)
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:4
New Member


--
07 Nov 2014 02:34 PM
    I am trying to loop through a number of images (1-band) and over a set of ROIs. I would like to export the pixel values from each ROI to a file for use in another program. I can write the data out using ENVI:ExportROIS, but would like to get the data into an array to add a few things. Here is a short code fragment. ? rast1=e.OpenRaster(files[0]) rois = e.OpenRoi(roifile) numrois = size(rois, /N_ELEMENTS) WHILE(counter LT numrois) DO BEGIN sROIfile = roidatfile+ String(counter, Format='(I3.3)') + '.csv' saveROIfile = FILEPATH(sROIfile, ROOT_DIR = savedir) rast1.ExportROIS, saveROIfile, rois[1], 'CSV' ENDWHILE This produces a file for each ROI with a number of header rows, then the pixel information. Like this: ; Number of ROIs: 1 ; File Dimension: 8001 x 7291 ; ROI name: Emerg01 ; ROI rgb value: {0 128 0} ; ROI npts: 10003 FileX, FileY, MapX, MapY, Lat, Lon, B1 3769, 2675, 347355, 4811865, 43.44413141, -118.8863774, -0.051635 I would like to loop over a number of ROIs, have all the data in one file but with an ROI# associated with each data point. For example, create a file with a single header row and include ROI information. Something like: ROI#, ROIName, FileX, FileY, ... B1 However, I don't know how to get the data from the rast1.ExportROIS command into a 2-d data array. If I could get the data into an array then I could just append a column with the ROI# and write it out. Something like (I know this doesn't work - I just want the data from the ExportROIS property in an array): dataArray = rast1.ExportROIS, ..... I actually want to loop over a number of files and create a single file with data like this: FileName, ROI#, FileX, FileY, .... BD Does anyone have any suggestions? Gus

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    22 Nov 2014 06:36 AM
    There is no way to customize the ascii output from ROIs with ENVI's routines, but you can design your own text output using something like IDL's PRINTF routine.
    You are not authorized to post a reply.