Skip to contents

Calculate the coefficient of variation (CV) of reflectance across all spectral bands for each pixel. CV is a standardized, dimensionless measure of spectral dispersion relative to mean brightness.

Usage

hsi_calc_rcv(
  x,
  index_name = NULL,
  na.rm = TRUE,
  filename = "",
  overwrite = FALSE,
  ...
)

Arguments

x

A SpatRaster with hyperspectral data.

index_name

Character. Name for the output layer. Default NULL.

na.rm

Logical. Remove NA values. Default TRUE.

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 coefficient of variation values.

Details

CV is calculated as sd / mean for each pixel across all wavelengths. Unlike standard deviation alone, CV normalizes for brightness differences, making it comparable across pixels with different mean reflectance values.

Examples

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

x_rcv <- hsi_calc_rcv(x)

x_rcv <- hsi_calc_rcv(
  x,
  index_name = "cv_reflectance",
  filename = "output_rcv.tif",
  overwrite = TRUE
)
} # }