ResampleSpectrum Task

This task resamples a given spectrum to a different set of wavelengths, typically from a hyperspectral image.

Example

; Launch the application

e = ENVI()

 

; Open a spectral library

specLibFile = FILEPATH('veg_2grn.sli', ROOT_DIR=e.ROOT_DIR, $

  SUBDIR=['resource', 'speclib', 'veg_lib'])

specLib = ENVISpectralLibrary(specLibFile)

 

; Open a hyperspectral image

file = FILEPATH('AVIRISReflectanceSubset.dat', $

  ROOT_DIR=e.ROOT_DIR, $

  SUBDIRECTORY = ['data', 'hyperspectral'])

raster = e.OpenRaster(file)

 

; Get wavelength units of raster

Task1 = ENVITask('RasterMetadataItem')

Task1.INPUT_RASTER = raster

Task1.KEY = 'Wavelength Units'

Task1.Execute

 

; Get wavelengths of raster

Task2 = ENVITask('RasterMetadataItem')

Task2.INPUT_RASTER = raster

Task2.KEY = 'Wavelength'

Task2.Execute

 

; Get the selected spectrum from spectral library

Task3 = ENVITask('GetSpectrumFromLibrary')

Task3.INPUT_SPECTRAL_LIBRARY = specLib

Task3.SPECTRUM_NAME = 'Dry Grass'

Task3.Execute

 

; Plot the spectrum

y3 = Task3.SPECTRUM

x3 = Task3.WAVELENGTHS

origPlot = PLOT(x3,y3, 'r2', $

  TITLE='Dry Grass (original)', $

  XTITLE='Wavelengths (um)', $
  YTITLE='Data Value')

 

; Get the resample spectrum task from the catalog of ENVITasks

Task4 = ENVITask('ResampleSpectrum')

 

; Define inputs

 

; Spectrum from library to be resampled

Task4.INPUT_SPECTRUM = Task3.SPECTRUM

 

; Wavelengths from spectral library

Task4.INPUT_WAVELENGTHS = Task3.WAVELENGTHS

 

; Wavelength units from spectral library

Task4.INPUT_WAVELENGTH_UNITS = Task3.WAVELENGTH_UNITS

 

; Wavelengths from raster

Task4.RESAMPLE_WAVELENGTHS = Task2.VALUE.VALUE

 

; Wavelength units from raster

Task4.RESAMPLE_WAVELENGTH_UNITS = Task1.VALUE.VALUE

 

; Run the resample spectrum task

Task4.Execute

 

; Plot the resampled spectrum

y4 = Task4.OUTPUT_SPECTRUM

x4 = Task3.WAVELENGTHS

specLibPlot = PLOT(x4,y4, 'g2', $

  TITLE='Dry grass (resampled)', $

  XTITLE='Wavelengths (um)', $
  YTITLE='Data Value')

Syntax

Result = ENVITask('ResampleSpectrum')

Input properties (Set, Get): INPUT_SPECTRUM, INPUT_WAVELENGTHS, INPUT_WAVELENGTH_UNITS, MISSING, RESAMPLE_WAVELENGTHS, RESAMPLE_WAVELENGTH_UNITS

Output properties (Get only): OUTPUT_SPECTRUM

Properties marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Properties marked as "Get" are those whose values you can retrieve but not set.

Methods

This task inherits the following methods from ENVITask:

AddParameter

Execute

Parameter

ParameterNames

RemoveParameter

Properties

This task inherits the following properties from ENVITask:

COMMUTE_ON_DOWNSAMPLE

COMMUTE_ON_SUBSET

DESCRIPTION

DISPLAY_NAME

NAME

REVISION

TAGS

This task also contains the following properties:

INPUT_SPECTRUM (required)

Specify an array that represents the spectrum to resample.

INPUT_WAVELENGTHS (required)

Specify an array that represents the wavelength values for a given spectrum.

INPUT_WAVELENGTH_UNITS (optional)

The units of the input wavelengths.

MISSING (optional)

Specify the value to use for a spectra that falls outside the input wavelength range. The default value is 0.

OUTPUT_SPECTRUM

The resampled output spectrum.

RESAMPLE_WAVELENGTHS (required)

Specify an array that represents the wavelengths to resample the input spectrum to. This can come from an image (using the RasterMetadataItem task) or from your own array of values.

RESAMPLE_WAVELENGTH_UNITS (optional)

The units to convert the resampled spectrum wavelengths to.

Version History

ENVI 5.3

Introduced

API Version

4.2

See Also

ENVITask, ENVISpectralLibrary, QuerySpectralLibrary Task, RasterMetadataItem Task, ENVIGetSpectrumFromLibrary