The ExportROIs method will output the pixel locations for a given ENVIROI with an ENVIDeepLearningLabelRaster to an ENVI Classic .roi file, a Comma Separated Value .csv file, or an ESRI Shapefile .shp. Shapefile output can be stored as points or geometry.

To save an ENVIROI to its native .xml format, use ENVIROI::Save.

This method is part of ENVI Deep Learning, which requires a separate license and installation.


Sample data files are available on our ENVI Tutorials web page. Click the "Deep Learning" link in the ENVI Tutorial Data section to download a .zip file containing the data. Extract the contents to a local directory.

; Launch the application
; Open a label raster
File = Filepath('LabelRasterContainers.dat', $
  Subdir=['data','deep_learning'], Root_Dir=e.Root_Dir)
Raster = ENVIDeepLearningLabelRaster(File)
; Open ROIs
; Open a label raster
ROIFile = Filepath('ShippingContainerROIs.dat', $
  Subdir=['data','deep_learning'], Root_Dir=e.Root_Dir)
rois = e.OpenRoi(ROIFile)
; Export ROIs to shapefile as geometry
Raster.ExportROIs, e.GetTemporaryFilename('shp'), rois, 'shapefile'
; Export ROIs to shapefile as points
Raster.ExportROIs, e.GetTemporaryFilename('shp'), rois, 'shapefile points'
; Export ROIs to classic .roi file
Raster.ExportROIs, e.GetTemporaryFilename('roi'), rois, 'classic'
; Export ROIs to CSV text file
Raster.ExportROIs, e.GetTemporaryFilename('csv'), rois, 'csv'


ENVIDeepLearningLabelRaster.ExportROIs, OutputFilename, ROI, Format [, ERROR=value]



The name of the output file to write.

  • If the Format is CLASSIC, the filename extension must be .roi.
  • If the Format is CSV, the filename extension must be .csv or .txt.
  • If the Format is SHAPEFILE or SHAPEFILE POINTS, the filename extension must be .shp.


An array of one or more ENVIROI objects used as the ROIs to export.


A scalar string denoting the format in which the ROI(s) will be saved. An error will be thrown if the format is unrecognized or unsupported. The valid string values are:

Format Strings



Export the input ROIs to an ENVI Classic file (.roi).


Export the input ROIs to a Comma Separated Value file (.csv or .txtgina).


Export the input ROIs to polygon shapefile file (.shp).

'shapefile points'

Export the input ROIs to multipoint shapefile file (.shp).



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 the Manage Errors topic in ENVI Help for more information on error handling.

Version History

Deep Learning 1.0


See Also