speclib | R Documentation |
Methods to create objects of class Speclib from various data sources such as matrixes and raster files (e.g. GeoTiff).
## S4 method for signature 'matrix,numeric' speclib(spectra, wavelength, ...) ## S4 method for signature 'SpatialGridDataFrame,numeric' speclib(spectra, wavelength, ...) ## S4 method for signature 'numeric,numeric' speclib(spectra, wavelength, ...) ## S4 method for signature 'matrix,data.frame' speclib(spectra, wavelength, ...) ## S4 method for signature 'SpatialGridDataFrame,data.frame' speclib(spectra, wavelength, ...) ## S4 method for signature 'numeric,data.frame' speclib(spectra, wavelength, ...) ## S4 method for signature 'matrix,matrix' speclib(spectra, wavelength, ...) ## S4 method for signature 'SpatialGridDataFrame,matrix' speclib(spectra, wavelength, ...) ## S4 method for signature 'numeric,matrix' speclib(spectra, wavelength, ...) ## S4 method for signature 'character,numeric' speclib(spectra, wavelength, ...) ## S4 method for signature 'Speclib,numeric' speclib(spectra, wavelength, ...) ## S4 method for signature 'Speclib' print(x) ## S4 method for signature 'Speclib' show(object) is.speclib(x)
spectra |
Data frame, matrix or raster object of class 'RasterBrick' or 'SpatialGridDataFrame' with spectral data. Alternatively, spectra may be the path to a raster file containing hyperspectral data. |
x,object |
Object to be converted to or from Speclib. For conversion to Speclib it can be a of class |
wavelength |
Vector with corresponding wavelength for each band. A matrix or data.frame may be passed giving the upper and lower limit of each band. In this case, the first column is used as lower band limit and the second as upper limit, respectively. |
... |
Further arguments passed to specific (generic) functions. Theey encompass particularly the following additional parameters:
|
The spectral data (usually reflectance values) are stored in an object of class '.Spectra'
. This object may eiter contain the spectral data as a RasterBrick
or as a matrix
with columns indicating spectral bands and rows different samples, respectively. The Speclib-class provides converting routines to and from RasterBrick
-class allowing to read and write geographic raster data via brick
. Since R is in general not intended to be used for VERY large data sets, this functionality should be handled with care. If raster files are large, one should split them in multiple smaller ones and process each of the small files, separately. See the excellent tutorial 'Writing functions for large raster files' available on https://CRAN.R-project.org/package=raster and section '2.2.2 Speclibs from raster files' in 'hsdar-intro.pdf'.
Speclib contains wavelength information for each band in spectral data. This information is used for spectral resampling, vegetation indices and plotting etc. Since spectra can be handled either as continuous lines or as discrete values like for satellite bands, spectral information is handled in two principle ways:
Continuous spectra: Data of spectrometers or hyperspectral (satellite) sensors. This data is plotted as lines with dotted lines indicating standard deviations by default.
Non-continuous spectra: Data of multispectral satellite sensors. Here, data is plotted as solid lines and error bars at the mean position of each waveband indicating standard deviations by default.
The kind of data may be chosen by the user by setting the flag "continuousdata"
(attr(x,
"continuousdata")
) or passing continuousdata = TRUE/FALSE
, when initially converting data to Speclib
-class. Take care of doing so, because some functions as spectralResampling
may only work correctly with continuous data!
The internal and recommended wavelength unit is nm. If Speclibs are created with wavelength values in other units than nm as passed by wlunit
-argument, wavelength values are automatically converted to nm. In this case, functions requiring to pass wavelength information (e.g., mask
etc) expect the unit to match the one initially set. The only exception is the Nri-class which always uses and expects nm as unit of passed wavelength values. The following units are automatically detected: mu, µm, nm, mm, cm, dm, m.
An object of class Speclib
contains the following slots:
wavelength: Vector with wavelength information. Always stored in nm.
fwhm: Vector or single numerical value giving the full-width-half-max value(s) for each band.
spectra: Object of class '.Spectra' with three slots:
fromRaster: logical, indicating if spectral data is read from a RasterBrick-object.
spectra_ma: Matrix with ncol = number of bands and nrow = number. Used if fromRaster == FALSE
spectra_ra: RasterBrick-object which is used if fromRaster == TRUE.
Contains reflectance, transmittance or absorbance values. Handle with function spectra
.
SI: Data frame containing additional data to each spectrum. May be used for linear regression etc. Handle with function SI
.
usagehistory: Vector giving information on history of usage of speclib. Handle with function usagehistory
.
An object of class Speclib
containing the following slots is returned:
wavelength: Vector with wavelength information. Always stored in nm.
fwhm: Vector or single numerical value giving the full-width-half-max value(s) for each band.
spectra: Object of class '.Spectra' with three slots:
fromRaster: logical, indicating if spectral data is read from a RasterBrick-object.
spectra_ma: Matrix with ncol = number of bands and nrow = number. Used if fromRaster == FALSE
spectra_ra: RasterBrick-object which is used if fromRaster == TRUE.
Contains reflectance, transmittance or absorbance values. Handle with function spectra
.
SI: Data frame containing additional data to each spectrum. May be used for linear regression etc. Handle with function SI
.
usagehistory: Vector giving information on history of usage of speclib. Handle with function usagehistory
.
rastermeta: List containing meta information to create *Raster objects from Speclib. Handle with function rastermeta
.
Lukas Lehnert
Speclib
, plot
, readGDAL
, mask
,
idSpeclib
, dim
, spectra
,
SI
data(spectral_data) spectra <- spectra(spectral_data) wavelength <- spectral_data$wavelength spectra <- speclib(spectra,wavelength)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.