<p>I am subsetting multiple rasters based on multiple ROI's with the following code:</p>
<p>pro allot_roi2<br />
e=ENVI()<br />
cd, current = first_dir<br />
<br />
;location where all 80 NDII VI's are located<br />
cd, 'F:\Sheyenne\Atmospherically Corrected Landsat\Indices\Main\no_trees\NDVI'<br />
files = FILE_SEARCH('*.dat', count=count)<br />
cd, first_dir<br />
<br />
;output location to save roi subsets to<br />
thisdir = 'F:\Sheyenne\GAP_analysis\NDVI_subset'<br />
<br />
;initiate loop on VI files<br />
foreach file, files do begin<br />
<br />
;input raster<br />
infile = file<br />
infile_path = FILEPATH(infile,ROOT_DIR='F:\Sheyenne\Atmospherically Corrected Landsat\Indices\Main\no_trees\NDVI')<br />
<br />
;save the date located within filename for later use<br />
date = strmid(infile_path,15,7, /REVERSE_OFFSET)<br />
; Load the input raster<br />
input_raster = e.OpenRaster(infile_path)<br />
;set new pathway where roi files are located<br />
cd, 'F:\Sheyenne\GAP_analysis\ROI'<br />
files2 = FILE_SEARCH('*.roi', count=count)<br />
foreach file, files2 do begin<br />
<br />
;input roi<br />
infile2=file<br />
infile_path2=FILEPATH(infile2, ROOT_DIR='F:\Sheyenne\GAP_analysis\ROI') <br />
;set name and location for output file which is the subseted data<br />
;get the name of the roi without extension for later use<br />
allotment=strmid(infile2, 0, strpos(infile2,'.'))<br />
outfile = 'NDVI_' + date +'_' + allotment + '.dat'<br />
outfile_path = thisdir + path_sep() + outfile<br />
;load input roi<br />
rois=e.OpenRoi(infile_path2)<br />
<br />
rasterWithMask=ENVIRoiMaskRaster(input_raster,rois)<br />
;<br />
; ;save the file<br />
rasterWithMask.Export,outfile_path, 'ENVI'<br />
endforeach<br />
endforeach<br />
print, 'Done Processing'</p>
<p>end</p>
<p>The code works with other roi's that I created, but I just made some new ones and I keep getting this error:</p>
<p><strong>ENVIROIMASKRASTER: Mask ROI does not contain any valid pixels for input raster</strong>.</p>
<p>when I restore the ROI's in the GUI they show up though and overly like they should. Any ideas why this might be happening? I created the roi's from a shapefile. </p>
<p><br />
</p>
<p><br />
</p>
|