X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 14 Nov 2015 11:51 AM by  anon
ROI does not contain valid pixels
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
14 Nov 2015 11:51 AM
    <p>I am subsetting multiple rasters based on multiple ROI's with the following code:</p> <p>pro allot_roi2<br /> &nbsp; e=ENVI()<br /> &nbsp; cd, current = first_dir<br /> <br /> &nbsp; ;location where all 80 NDII VI's are located<br /> &nbsp; cd, 'F:\Sheyenne\Atmospherically Corrected Landsat\Indices\Main\no_trees\NDVI'<br /> &nbsp; files = FILE_SEARCH('*.dat', count=count)<br /> &nbsp; cd, first_dir<br /> <br /> &nbsp; ;output location to save roi subsets to<br /> &nbsp; thisdir = 'F:\Sheyenne\GAP_analysis\NDVI_subset'<br /> <br /> &nbsp; ;initiate loop on VI files<br /> &nbsp; foreach file, files do begin<br /> <br /> &nbsp; &nbsp; ;input raster<br /> &nbsp; &nbsp; infile = file<br /> &nbsp; &nbsp; infile_path = FILEPATH(infile,ROOT_DIR='F:\Sheyenne\Atmospherically Corrected Landsat\Indices\Main\no_trees\NDVI')<br /> <br /> &nbsp; &nbsp; ;save the date located within filename for later use<br /> &nbsp; &nbsp; date = strmid(infile_path,15,7, /REVERSE_OFFSET)<br /> ; &nbsp; &nbsp;Load the input raster<br /> &nbsp; &nbsp; input_raster = e.OpenRaster(infile_path)<br /> &nbsp; &nbsp; ;set new pathway where roi files are located<br /> &nbsp; &nbsp; cd, 'F:\Sheyenne\GAP_analysis\ROI'<br /> &nbsp; &nbsp; files2 = FILE_SEARCH('*.roi', count=count)<br /> &nbsp; &nbsp; foreach file, files2 do begin<br /> <br /> &nbsp; &nbsp; &nbsp; ;input roi<br /> &nbsp; &nbsp; &nbsp; infile2=file<br /> &nbsp; &nbsp; &nbsp; infile_path2=FILEPATH(infile2, ROOT_DIR='F:\Sheyenne\GAP_analysis\ROI') &nbsp;&nbsp;<br /> &nbsp; &nbsp; &nbsp; ;set name and location for output file which is the subseted data<br /> &nbsp; &nbsp; &nbsp; ;get the name of the roi without extension for later use<br /> &nbsp; &nbsp; &nbsp; allotment=strmid(infile2, 0, strpos(infile2,'.'))<br /> &nbsp; &nbsp; &nbsp; outfile = 'NDVI_' + date +'_' + allotment + '.dat'<br /> &nbsp; &nbsp; &nbsp; outfile_path = thisdir + path_sep() + outfile<br /> &nbsp; &nbsp; &nbsp; ;load input roi<br /> &nbsp; &nbsp; &nbsp; rois=e.OpenRoi(infile_path2)<br /> <br /> &nbsp; &nbsp; &nbsp; rasterWithMask=ENVIRoiMaskRaster(input_raster,rois)<br /> ;<br /> ; &nbsp; &nbsp; &nbsp;;save the file<br /> &nbsp; &nbsp; &nbsp; rasterWithMask.Export,outfile_path, 'ENVI'<br /> &nbsp; &nbsp; endforeach<br /> &nbsp; endforeach<br /> &nbsp; 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. &nbsp;Any ideas why this might be happening? &nbsp;I created the roi's from a shapefile.&nbsp;</p> <p><br /> </p> <p><br /> </p>

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    16 Nov 2015 12:47 PM
    Were your previous ROIs drawn on the full size (not subset) image?&nbsp; I believe this problem is caused by subsetting the image and the x/y offsets in the header.&nbsp; If you remove the x/y offsets and use your ROIs (not classic ROIs) does it still give you an error?

    Deleted User



    New Member


    Posts:
    New Member


    --
    17 Nov 2015 12:56 PM
    <p>It was because my ROI's were not contiguous. &nbsp;There were bits and pieces all over the image and I guess ENVI doesn't like that. &nbsp;They were essentially polygons covering different portions of the image.&nbsp;</p>
    You are not authorized to post a reply.