Skip to contents

Normalize spectra by removing the spectral continuum to highlight absorption features. The continuum is the convex hull connecting local maxima across the spectrum. Requires the prospectr package.

Usage

hsi_remove_continuum(x, filename = "", overwrite = FALSE, ...)

Arguments

x

A SpatRaster with hyperspectral data.

filename

Character. Output filename. Default "" keeps result in memory.

overwrite

Logical. Overwrite existing file. Default FALSE.

...

Additional arguments passed to terra::writeRaster().

Value

A SpatRaster with continuum-removed values.

Details

Output values are bounded [0, 1] by definition — each band is divided by its continuum value.

Degenerate spectra for which no valid continuum exists (e.g. cracks, all-zero or constant spectra, pixels containing NA) return NA in all bands instead of aborting the computation. Inspect the NA pattern of the result if coverage looks unexpectedly sparse.

Wavelengths are taken from band names. If band names cannot be converted to numeric wavelengths, band indices are used instead and a warning is issued.

Computationally intensive; consider applying to subsets or regions of interest rather than full-resolution data. For full-raster processing, hsi_tiled() can distribute the workload across parallel workers.

Examples

if (FALSE) { # \dontrun{
x <- terra::rast("REFLECTANCE_testdata.tif")

x_crem <- hsi_remove_continuum(x)

x_crem <- hsi_remove_continuum(
  x,
  filename = "output_crem.tif",
  overwrite = TRUE
)
} # }