Skip to content

Indices

This module defines the SpectralIndex data structure and a registry of common spectral indices.

IndexCatalog

Source code in src/phytospatial/raster/indices.py
class IndexCatalog:
    def __init__(self):
        self._indices = {
            "NDVI": SpectralIndex("NDVI", "(nir - red) / (nir + red)", {"nir": 850.0, "red": 650.0}),
            "OTHER INDEX": SpectralIndex("OTHER INDEX", "SOME FORMULA", {"BANDNAME1": 700.0, "BANDNAME2": 500.0})
        }

    def get(
            self, 
            name: str
            ) -> SpectralIndex:
        """
            Retrieve a SpectralIndex by name from the catalog.

            Args:
                name (str): The name of the spectral index to retrieve.

            Returns:
                SpectralIndex: The corresponding SpectralIndex object.
        """
        return self._indices[name]

    def register(
            self, 
            index: SpectralIndex
            ) -> None:
        """
            Register a new SpectralIndex in the catalog.

            Args:
                index (SpectralIndex): The SpectralIndex object to register.

            Returns:
                None
        """
        self._indices[index.name] = index

get(name)

Retrieve a SpectralIndex by name from the catalog.

Parameters:

Name Type Description Default
name str

The name of the spectral index to retrieve.

required

Returns:

Name Type Description
SpectralIndex SpectralIndex

The corresponding SpectralIndex object.

Source code in src/phytospatial/raster/indices.py
def get(
        self, 
        name: str
        ) -> SpectralIndex:
    """
        Retrieve a SpectralIndex by name from the catalog.

        Args:
            name (str): The name of the spectral index to retrieve.

        Returns:
            SpectralIndex: The corresponding SpectralIndex object.
    """
    return self._indices[name]

register(index)

Register a new SpectralIndex in the catalog.

Parameters:

Name Type Description Default
index SpectralIndex

The SpectralIndex object to register.

required

Returns:

Type Description
None

None

Source code in src/phytospatial/raster/indices.py
def register(
        self, 
        index: SpectralIndex
        ) -> None:
    """
        Register a new SpectralIndex in the catalog.

        Args:
            index (SpectralIndex): The SpectralIndex object to register.

        Returns:
            None
    """
    self._indices[index.name] = index