I am having some problems. I want to load a number of images and clip out a small rectangle defined by an ROI, then save this smaller file to disk.
When I subset using an ROI rather than a sub_rect, the file is not reduced (it masks the raster rather than clipping it).
Is there a why to clip (subset) with an ROI? If not, is there a way to get the sub_rect from an ROI to I can subset using the sub_rect method?
Here is the code I am trying to use (I cut out most of the extraneous stuff, e.g., file names, directories, etc).
In the code below, if I view "smallraster" it is the region I am interested in. However, "savefile" has the full image, not clipped to the ROI.
; Use ENVI 5.1 stuff - won't work on 4.xxx
; Start ENVI
e = ENVI(/CURRENT)
; Open the base file
raster1 = e.OpenRaster(file1)
; Open the ROI file to set the clipping area
roifile = Filepath('MlhLkCropROI.xml', ROOT_DIR = dir)
rois = e.OpenRoi(roifile)
savedir = 'Z:\RS_Work\IDLTest\Crop'
savefile = FILEPATH('Test', ROOT_DIR = savedir)
rastersmall = ENVIRaster(URI='savefile', INHERITS_FROM=raster1)
rastersmall = raster1.subset(ROI=rois)
rastersmall.Export, savefile, 'ENVI'
END
|