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
|