ENVIROI::Save
The Save method saves an ENVIROI to an .xml
file. After calling Save, the ENVIROI is still available for display.
If the .xml
file does not exist, the Save method creates a new file.
If the .xml
file exists, new ROIs are appended to the end of the file. If the given ROI is already contained in the .xml
file, it is updated.
Example
For the following example:
- Copy and paste the procedure into an IDL editor window.
- Save the file as
enviroi_save_example.pro
. - Compile and run the procedure.
PRO enviroi_save_example
compile_opt idl2
; Launch the application
e = ENVI()
; Create an ROI
file = FILEPATH('qb_boulder_pan', ROOT_DIR=e.ROOT_DIR, $
SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file)
view = e.GetView()
layer = view.CreateLayer(raster)
roi1 = EnviRoi(NAME='Sun Reflectance', COLOR='Red')
; Iterate through the tiles of the original data set
tileIterator = raster.CreateTileIterator()
FOREACH data, tileIterator DO BEGIN
ptr = WHERE(DATA GT 1000 AND data LT 1530, COUNT)
IF (COUNT GT 0) THEN BEGIN
x = (tileIterator.Current_Subrect)[0] + $
(ptr mod (tileIterator.Tile_Size)[0])
y = (tileIterator.Current_Subrect)[1] + $
(ptr / (tileIterator.Tile_Size)[0])
roi1.AddPixels, Transpose([[x],[y]]), spatialref=raster.spatialref
ENDIF
ENDFOREACH
roi1.AddThreshold, raster, 0, MIN_VALUE=1000, MAX_VALUE=1530
visRoi1 = layer.AddRoi(roi1)
; Create an ROI file
newFile = e.GetTemporaryFilename('.xml')
roi1.Save, newFile
END
Syntax
ENVIROI.Save, URI [, ERROR=variable]
Arguments
URI
A scalar string that is a fully-qualified file path to a new or existing ENVI ROI .xml
file to which the ROI data should be written.
Keywords
ERROR
Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''
). If an error occurs and the routine is a function, then the function result will be undefined.
When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.
See Manage Errors for more information on error handling in ENVI programming.
Version History
ENVI 5.1 |
Introduced |
API Version
4.2