pyprecag.bandops

class pyprecag.bandops.BandMapping(*args, **kwargs)[source]

A dictionary used to manage band types and band numbers.

If it has not been set it will have the default value of 0

The list of keys is confined to those in __defaults, values must be integers.

__defaults = values to use as defaults
__init__(*args, **kwargs)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

allocated_bands()[source]

Get a list of bands numbers already allocated to a band type ie not zero.

class pyprecag.bandops.CalculateIndices(**kwargs)[source]

Functions used for validating and calculating image indices.

Parameters:() (**kwargs) – Components of the BandMapping object
__init__(**kwargs)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

calculate(index_name, raster, src_nodata=None, dest_nodata=-9999)[source]
Using a given raster, calculate an image index. Valid indices include.
NDVI - Normalised difference vegetation index PCD - Plant cell density index GNDVI - Green normalised difference vegetation index CHLRE - Chlorophyll red-edge index NDRE - Normalised difference red-edge index
Parameters:
  • index_name (str) – The name of the index to calculate options include NDVI, PCD, GNDVI, NDRE and CHLRE
  • raster (str) – The input raster. This can be a filename, rasterio.io.Memoryfile or opened rasterio dataset
  • src_nodata (int) – The nodata value of the image. This will only be used if the input raster has a value of None
  • dest_nodata (int) – The value to use as the output no data value. If np.nan is required use None
Returns:

The result of the index calculation

Return type:

numpy.ndarray

chlre()[source]

Calculate a Chlorophyll Red-edge index. Requires Red-edge and InfraRed Bands

gndvi()[source]

Calculate a normalised difference vegetation index. Requires Green and InfraRed Bands

ndre()[source]

Calculate a normalised difference red-edge index. Requires Red-edge and InfraRed Bands

ndvi()[source]

Calculate a normalised difference vegetation index. Requires Red and InfraRed Bands

pcd()[source]

Calculate a plant cell density index. Requires Red and InfraRed Bands

valid_indices()[source]

Generate a list of indices supported by the band mapping