Learn R Programming

hsdar (version 0.5.1)

dist.speclib: Distance between spectra

Description

Calculation of distance matrices by using one of the various distance measure to compute the distances between the spectra in Speclib. Spectral Angle Mapper (SAM) is calculated with sam giving reference spectra or with sam_distance taking all combinations between spectra in single Speclib into account.

Usage

dist.speclib(x, method = "sam", ...)
## Direct call to Spectral Angle Mapper function sam(x, ref) sam_distance(x)

Arguments

x
Object of class Speclib.
method
The distance measure to be used. This must be one of "sam", "euclidean", "maximum", "manhattan", "canberra", "binary" or "minkowski".
ref
Object of class Speclib containing reference spectra.
...
Further arguments, passed to other methods.

Value

The dist-method for Speclibs returns an object of class "dist". See dist for further information on class "dist". Both other functions return an object of class matrix.

Details

Available distance measures are "spectral angle mapper" (sam) and all distance measures available in dist. Spectral angle mapper is calculated with the following formula: $$sam=\cos^{-1}\left(\frac{\sum_{i=1}^{nb}{t_i r_i}}{\sqrt{\sum_{i=1}^{nb}{t_i^2}}\sqrt{\sum_{i=1}^{nb}{r_i^2}}}\right)$$ $nb$ is the number of bands in Speclib. $t_i$ and $r_i$ are the reflectances of target and reference spectrum in band $i$, respectively.

References

Kruse, F. A.; Lefkoff, A. B.; Boardman, J. W.; Heidebrecht, K. B.; Shapiro, A. T.; Barloon, P. J. & Goetz, A. F. H. (1993). The spectral image processing system (SIPS) -- interactive visualization and analysis of imaging spectrometer data. Remote Sensing of Environment, 44, 145-163.

See Also

dist, Speclib

Examples

Run this code
data(spectral_data)

## Mask channel crossing part (arround 1050 nm) and strong 
## water absorption part (above 1350 nm)
mask(spectral_data) <- c(1045, 1055, 1350, 1706)

## Calculate distance between all spectra from spring 
## using spectral angle mapper 
dist.speclib(subset(spectral_data, season == "spring"))


## Calculate spectral angle mapper between reference spectrum
## and spectral_data
## Use first spectrum from summer as reference
distance <- sam(subset(spectral_data, season == "spring"), 
                subset(spectral_data, season == "summer")[1,])

Run the code above in your browser using DataLab