toolsrtm.indices
~75 VNIR + ~18 SWIR spectral vegetation indices from a reflectance
spectrum. Direct port of ToolsRTM/R/getIndices.R.
Spectral vegetation indices, direct port of ToolsRTM::getIndices.
The R function takes a dataframe with named reflectance columns
(R.400, R.670, …) and a regex pattern to find them; the Python
port instead takes wavelengths/reflectance arrays directly (the
numerically load-bearing part – linear interpolation onto an integer nm
grid, then per-index algebra on named wavelengths – is unchanged, only the
dataframe-column-parsing convenience layer is dropped, since it doesn’t
change any numbers).
A handful of formulas below are reproduced as literally written in the R
source, bugs included, rather than “fixed” – see the inline notes at
CIgreen and TCARI/OSAVI.1510, and the GnyLi/CI2 overwrite
sequences – so results match R exactly for anyone cross-checking against
the original package.
- toolsrtm.indices.get_indices(wavelengths, reflectance, spectral_domain='VNIR', factor=None)[source]
Common spectral vegetation indices from reflectance spectra.
Direct port of
ToolsRTM::getIndices(the reflectance-column parsing viapattern.rflis replaced by passingwavelengths/reflectancedirectly – see module docstring).- Parameters:
wavelengths (array_like, shape (nwl,)) – Wavelengths (nm) of the
reflectancecolumns.reflectance (array_like, shape (nwl,) or (nsamples, nwl)) – Reflectance spectra (0-1), one or more rows.
spectral_domain ({'VNIR', 'SWIR', 'VNIR-SWIR'}) – ‘VNIR’: indices using 400-850 nm bands. ‘SWIR’: indices using 800-2550 nm bands. ‘VNIR-SWIR’: both.
factor (float, optional) – Scaling factor applied to reflectance (e.g. 1/10000 for digital numbers). Default 1 (no scaling).
- Returns:
{index_name: numpy.ndarray of shape (nsamples,)}.- Return type:
dict