Learn R Programming

RStoolbox (version 0.1.1)

readSLI: Read ENVI spectral libraries

Description

read/write support for ENVI spectral libraries

Usage

readSLI(path)

Arguments

path
Path to spectral library file with ending .sli.

Value

  • The spectral libraries are read into a data.frame. The first column contains the wavelengths and the remaining columns contain the spectra.

Details

ENVI spectral libraries consist of a binary data file (.sli) and a corresponding header (.hdr, or .sli.hdr) file.

See Also

writeSLI

Examples

Run this code
## Create fake spectra
data <- data.frame(wavelength=350:2500, spectrumA=cumsum(abs(rnorm(2151))),
						spectrumB=cumsum(abs(rnorm(2151))))
pathToFile <- paste0(tempdir(),"/specLib.sli")

## Write to binary spectral library
writeSLI(x = data, path = pathToFile)

## Read from binary spectral library
dataRe <- readSLI(path = pathToFile)

## Check whether they are the same
all.equal(data, dataRe)

Run the code above in your browser using DataLab