Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.

  >  Docs Center  >  ENVI API  >  Display Control  >  ENVIView::CreateLayer



The CreateLayer function method creates and returns a new ENVIRasterLayer or ENVIVectorLayer object. The layer is displayed in the parent view.


; Launch the application
e = ENVI()
; Create an ENVIRaster
file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $
  SUBDIRECTORY = ['data'])
raster = e.OpenRaster(file)
view = e.GetView()
; Create a true-color layer
layer = view.CreateLayer(raster)


Result = ENVIView.CreateLayer(Data [, Keywords=value])

Return Value

This method returns a reference to the ENVIRasterLayer or ENVIVectorLayer object.



Specify one of the following:

  • An ENVIRaster object. If you do not specify any keywords, the layer is created as a true-color or greyscale image.
  • An ENVIVector layer
  • A string of the base filename of world data included with your ENVI installation (accessed through the File > Open World Data menu). Data courtesy of Natural Earth. Valid strings include coastlines, countries, geographic_lines, lakes, minor islands, populated_places, ports, rivers, roads, states_provinces, gmted2010, and shaded_relief.


Keywords are applied only during the initial creation of the object.


Set this keyword to a one-element array specifying the band index to be displayed, or a three-element array specifying the band indices (0-based) to be displayed as R, G, and B. This keyword is valid only if Data is an ENVIRaster. See Open Files for details on how ENVI automatically determines the bands to display. If the 'default bands' field is set in the associated ENVI header file, then those bands will be displayed.


Set this keyword to load a color-infrared (CIR) image if Data is an ENVIRaster. This keyword is ignored if BANDS is set, and it takes precedence over any default bands values set in the metadata.


If this keyword is set, all of the layers will be removed from the view prior to displaying the new layer.


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.


Set this keyword to load a true-color RGB image if Data is an ENVIRaster. This keyword is ignored if BANDS is set, and it takes precedence over any default bands values set in the metadata.

Version History



ENVI 5.1

Added RGB keyword

API Version


See Also

ENVIView, ENVIRasterLayer, ENVIView::GetLayer

© 2018 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us