# dist_speclib: Distance between spectra In hsdar: Manage, Analyse and Simulate Hyperspectral Data

## 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

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

## Arguments

 x Object of class Speclib. Note that spectra in x must be in range [0,1]. 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.

## Details

Available distance measures are "spectral angle mapper" (sam, Kruse et al. 1993) and all distance measures available in dist. Spectral angle mapper is calculated with the following formula:

\cos^{-1}(∑_{i=1}^{nb}{t_i r_i} ∑_{i=1}^{nb}{t_i^2}^{-0.5} ∑_{i=1}^{nb}{r_i^2}^{-0.5})

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.

## 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.

Lukas Lehnert

## 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.

dist, Speclib
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 data(spectral_data) ## Mask channel crossing part (around 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,])