ENVISpectralLibrary
This is a reference to an ENVISpectralLibrary object. You can create one from a .sli
file on disk, or you can create an empty one and add spectra to it.
When creating an empty ENVISpectralLibrary object, set the following properties on the object:
BBL
(optional): An array of bad band multiplier values of each band in an image, typically 0 for bad bands and 1 for good bands.DESCRIPTION
(optional): A string that describes the spectral libraryREFLECTANCE_SCALE_FACTOR
(optional): The value that, when divided into your data, would scale it from 0-1 reflectance. For example, if the value of 10,000 in your data represents a reflectance value of 1.0, enter a reflectance scale factor of 10,000. The default value is 1.0.WAVELENGTH_UNITS
(optional): A text string indicating the wavelength units. See thewavelength_units
description in The ENVI Header Format for a list of valid strings.WL
(required): An array of center wavelength valuesYRANGE
(optional): A two-element array of values indicating the minimum and maximum Y-values to use when plotting the spectral library
Finally, use the AddSpectra method to add spectra to the library. See the second code example below.
Example
This example creates an ENVISpectralLibrary object from a spectral library file (.sli
) on disk.
; Start the application
e = ENVI(/HEADLESS)
; Open a spectral library from the distribution
specLibFile = FILEPATH('veg_1dry.sli', ROOT_DIR=e.ROOT_DIR, $
SUBDIR=['resource', 'speclib', 'veg_lib'])
specLib = ENVISpectralLibrary(specLibFile)
; print the spectra names
Print, specLib.SPECTRA_NAMES
The next example creates a new, empty ENVISpectralLibrary object and adds spectra to it. Follow these steps to run the example:
- Copy and paste the code into a new window in the IDL Editor.
- Save the file as
NewSpectralLibrary.pro
. - Compile and run the program.
- When the Spectral Library Viewer appears, click each spectrum name to plot it.
PRO NewSpectralLibrary
COMPILE_OPT IDL2
; Start the application
e = ENVI()
; Create a new spectral library
specLibName = e.GetTemporaryFilename('sli')
specLib = EnviSpectralLibrary(specLibName)
; Set the WL (wavelength) property
specLib->SetProperty, WL=.4 + FINDGEN(25) * .1
; Add spectra
FOR i=1,5 DO BEGIN
name = 'Spectra #' + STRTRIM(i,2)
specLib.AddSpectra, name, Randomu(seed,25)
ENDFOR
; Smooth the spectra
FOR i=1,5 DO BEGIN
name = 'Spectra #' + STRTRIM(i,2)
spectra = specLib->GetSpectrum(name)
specLib.AddSpectra, name + ' (Smooth)', SMOOTH(spectra.Spectrum,5)
ENDFOR
; Plot the spectral library
specLib = ENVISpectralLibrary(specLibName, /LOAD)
END
Syntax
Result = ENVISpectralLibrary(URI [, ERROR=variable] [, Properties=value])
Return Value
This function returns a reference to an ENVISpectralLibrary object.
Arguments
URI
Specify a fully qualified path and filename to a spectral library file (.sli
).
Or, use the ENVI::GetTemporaryFilename method to create an empty ENVISpectralLibrary object. See the second code example above.
Methods
Keywords
ERROR (optional)
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.
LOAD (optional)
Set this keyword to plot the spectral library in the ENVI Spectral Library Viewer.
Properties
Properties marked as (Get) can be retrieved, but not set.
DESCRIPTION (Get)
A description of the library.
SPECTRA_NAMES (Get)
A string array containing the spectra names in the library.
Version History
ENVI 5.3 |
Introduced |
ENVI 5.3.1 |
Added Dehydrate method |
ENVI 5.4 |
Added Hydrate method |
ENVI 5.5.3 |
Added AddSpectra and RemoveSpectra methods; Added LOAD keyword |
API Version
4.2
See Also
ENVISpectralLibrary::GetSpectrum, GetSpectrumFromLibrary Task, QuerySpectralLibrary Task, ResampleSpectrum Task