Skip to main content

health

Objects

Options

@dataclass
class Options()

Input raster creation options

Attributes:

  • nodata float | int, optional - Specify the nodata value. Bear in mind that nodata values within the expected range of the vegetation index will cause holes in the final resulting raster dataset. Defaults to -9999.
  • normalize bool, optional - Input switch to normalize the data between [-1, 1]. Defaults to False.
  • COMPRESS str, optional - Choose a GDAL compression. Defaults to DEFLATE.
  • PREDICTOR str, optional - Use with compression to allow even greater compression power. Defaults to "2".
  • TILED str, optional - Add internal tiling for raster data. Defaults to YES.

generate_gdal_options

def generate_gdal_options(
ops: Literal["translate", "vrt", "warp"] = "translate",
form: Literal["gdal", "list"] = "gdal") -> list | Any | None

Function to convert input options into GDAL options.

Arguments:

  • ops Literal["translate", "vrt", "warp"], optional - the GDAL operation. Defaults to "translate". from (Literal["gdal", "list"])

Returns:

list | Any | None: a processing options object.

Functions

affinition

def affinition(
tile: gdal.Dataset | str,
options: Options | None = None,
dimension: Tuple[int, int] = (5000, 5000)
) -> gdal.Dataset

Function to create the GDAL output object from either a source dataset or a DynamoDB item.

Arguments:

  • tile gdal.Dataset - input raster dataset.
  • dimension Tuple[int, int], optional - input dimensions of the output tiff. Defaults to (5000, 5000).
  • options Options, optional - input options for raster creation.

Returns:

  • gdal.Dataset - output dataset used to write array to.

calculate

def calculate(tile: str | gdal.Dataset,
options: Options | None,
source_type: Literal["rgb", "infrared", "multispectral"],
which_index: str = "") -> io.BytesIO | None

Function to run the vegetation index calculations based on the input index given and its sensor type. RGB sensor type will not run an NDVI calculation. For NIR calculations you should use the NIR tile as tile input. The function will search for the RGB tile by itself. Multispectral data will assume a band order of [RED, RedEdge, NIR], from shortest wavelength to longest. Multispectral information holding more bands than these need to be spliced and reconfigured.

Arguments:

  • tile str | gdal.Dataset - input raster tile, can be a path or and gdal data object.
  • options Options, optional - input options for raster creation.
  • source_type Literal["rgb", "infrared", "multispectral"] - input sensor type.
  • which_index str, optional - the vegetation index name. Defaults to "".

Raises:

  • NotImplementedError - when a specific vegetation index isn't implemented in vi.py yet.

Returns:

io.BytesIO | None: a buffer object which contains the array of data and the GDAL object reference. To be used with utils.s3 functions to upload the data to AWS S3.

clip

def clip(tile: str | gdal.Dataset, shape: str) -> gdal.Dataset | None

Wrapper function around gdal.Warp to load the shapefile and process the clip.

Arguments:

  • tile str | gdal.Dataset - input tile.
  • shape str - input clip shape.

Returns:

  • gdal.Dataset | None: clipped gdal raster data

track_rgb

def track_rgb(tile: gdal.Dataset | str, prefix: str = "") -> str

Function to mine the matching RGB tile to a NIR tile.

Arguments:

  • tile gdal.Dataset | str - input NIR dataset.
  • prefix str, optional - add a prefix to the tile when a base tile key is used. Defaults to "".

Raises:

  • FileNotFoundError - matching RGB tile isn't found in filesystem

Returns:

  • str - matched RGB tile