Skip to contents

Calculate normalized difference index (NDI)

Usage

hsi_calc_ndi(
  x,
  bands,
  index_name = NULL,
  filename = "",
  overwrite = FALSE,
  ...
)

Arguments

x

A SpatRaster with hyperspectral data.

bands

Numeric vector of length 2. Wavelengths in nm.

index_name

Character. Name for the output layer. Default NULL.

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 NDI values.

Examples

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

x_ndi <- hsi_calc_ndi(
  x,
  bands = c(570, 690)
)

x_ndi <- hsi_calc_ndi(
  x,
  bands = c(570, 690),
  index_name = "ndi570690",
  filename = "output_ndi.tif",
  overwrite = TRUE
)
} # }