Learn R Programming

RStoolbox (version 0.1.1)

writeSLI: Write ENVI spectral libraries

Description

Writes binary ENVI spectral library files (sli) with accompanying header (.sli.hdr) files OR ASCII spectral library files in ENVI format.

Usage

writeSLI(x, path, wavl.units = "Micrometers", scaleF = 1, mode = "bin")

Arguments

x
data.frame with first column containing wavelengths and all other columns containing spectra.
path
path to spectral library file to be created.
wavl.units
wavelength units. Defaults to Micrometers. Nanometers is another typical option.
scaleF
optional reflectance scaling factor. Defaults to 1.
mode
character string specifying output file type. Must be one of "bin" for binary .sli files or "ASCII" for --guess what-- ASCII spectral library files (still in an ENVI compatible format).

Details

ENVI spectral libraries with ending .sli are binary arrays with spectra saved in rows.

See Also

readSLI

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