Skip to contents

Find band index positions by matching requested wavelengths to the nearest available band. When multiple requested wavelengths resolve to the same band index, only the last is retained.

Usage

wavelength_position(x, wavelength)

Arguments

x

A SpatRaster with hyperspectral data.

wavelength

Numeric vector. Desired wavelengths in nm.

Value

A tibble with columns:

wavelength

Numeric. Requested wavelength in nm.

position

Integer. Corresponding band index in x.

band_wavelength

Numeric. Actual wavelength of the matched band in nm.

Examples

if (FALSE) { # \dontrun{
r <- terra::rast(nrows = 10, ncols = 10, nlyrs = 5)
names(r) <- c("400", "500", "600", "700", "800")

wavelength_position(r, c(450, 650))
} # }