chBLCext: Convex hull function used for regions of interest

Description Usage Arguments Value References Examples

View source: R/chBLCext.R

Description

This function fits a convex hull to the region of interest. The regions of interest are reflectance of absorbance of some secondary clay minerals or iron oxides from vis-NIR spectra. Only one spectrum can be provided, not a spectra table.

Usage

1
chBLCext(spectra, type, wav, ...)

Arguments

spectra

Pre-processed spectrum for the region of interest. Only one spectrum can be provided.

type

Either 'A' of the spectrum is in absorbance, or 'R' if the spectrum is in reflectance.

wav

Vector numeric containing the wavelengths the of spectra argument.

...

Additional arguments to be passed to the function.

Value

A list with the following arguments:

wave

a vector of the wavelengths for the trimmed spectra.

cHull

the fitted convex hull to the region of interest.

rawSpec

the raw spectra used for trimming.

continuum

the continuum removed spectra.

polygon

the polygon of the area between the continnum removed spectra and the line of the convex hull.

References

Clark, R.N., and Roush, T.L., 1984. Reflectance Spectroscopy: Quantitative Analysis Techniques for Remote Sensing Applications. J. Geophys. Res. 89, 6329-6340.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require(soilspec)

# load the reference spectra
data("mineralRef")

# inspect the object
str(mineralRef)

# create a sequence of number to represent the wavelength
wavelength <- seq(350, 2500, by = 1)

#Function for trimming spectra or targeting a specific spectral region of #interest

trimSpec <- function(spectra, wavlimits){
  datawavs <- as.numeric(colnames(spectra))
  limits <- which(is.element(datawavs, wavlimits))
  keptIndex <- seq(limits[1], limits[2], 1)
  trimmedSpectra <- spectra[, keptIndex]
  keptNames <- datawavs[keptIndex]
  colnames(trimmedSpectra) <- keptNames
  return(trimmedSpectra)
}

# select reference mineral
montRef <- as.data.frame(t(mineralRef$kaolinite_114))
colnames(montRef) <- wavelength

# diagnostic wavelengths
lower <- 2078
upper <- 2267

# spectrum trimming
montDiog1 <- trimSpec(montRef,
                      wavlimits = range(lower:upper))

montDiog1CR <- chBLCext(spectra = montDiog1, wav = as.numeric(colnames(montDiog1)), type = 'R')

# plot the region of interest and the fitted convex hull to the continuum removed spectra
plot(seq(from = lower, to = upper, by = 1), montDiog1[1,],
     type = "l",
     xlab = "Wavelength /nm",
     ylab = "Reflectance")

# continuum removed spectra
lines(seq(from = lower, to = upper, by = 1), montDiog1CR$continuum,
      col = "red")

# band depth
sCr <- montDiog1CR[[3]][which(montDiog1CR[[2]]==min(montDiog1CR[[2]]))]
sL <- montDiog1CR[[4]][which(montDiog1CR[[2]]==min(montDiog1CR[[2]]))]
featureBd <- 1 - sCr/sL
featureBd

AlexandreWadoux/soilspec documentation built on March 7, 2021, 1:54 p.m.