Compute Index
This module provides functionality to generate spectral indices from raster data.
calculate_index_block(raster, formula, band_mapping)
Calculate a spectral index for a block of raster data using a provided formula and band mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raster
|
Raster
|
Input Raster object containing the spectral bands. |
required |
formula
|
str
|
A string representing the mathematical formula for the index, using variable names corresponding to the band_mapping keys. |
required |
band_mapping
|
Dict[str, int]
|
A dictionary mapping variable names in the formula to 1-based band indices in the raster. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Raster |
Raster
|
A new Raster object containing the calculated index as a single band. |
Source code in src/phytospatial/raster/compute_index.py
generate_index(input_path, output_path, index_name, max_tolerance=20.0)
Generates a specified vegetation index from an input orthomosaic raster and saves the result to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_path
|
Union[str, Path]
|
File path to the input orthomosaic raster containing the necessary spectral bands. |
required |
output_path
|
Union[str, Path]
|
File path where the output index raster will be saved. |
required |
index_name
|
str
|
The name of the vegetation index to compute. |
required |
max_tolerance
|
float
|
Maximum tolerance for wavelength matching. Defaults to 20.0 nm. |
20.0
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
The file path to the generated index raster. |