tutorialsreferenceguide

Analytics

The SPAI Library also contains some pre-defined analytical building blocks that generate multiple layers and analytics related to different use cases inside the analytics module.

The structure of the analytics module is as following:

/analytics
 |- forest-monitoring.py
 |- water-quality.py

forest_monitoring

The forest_monitoring function processes satellite imagery for an identified area of interest (AOI) to monitor vegetation using the Normalised Difference Vegetation Index (NDVI). It calculates and categorizes the NDVI, applies a vegetation threshold, masks the results to the specified AOI, colorizes the categorized NDVI and vegetation layers for visualization, and calculates the area in hectares of different vegetation quality classes within the AOI.

def forest_monitoring(image_name, date, aoi_mask, storage, prefix, names):

Parameters:

  • image_name: A string representing the name of the satellite image file (including the date and file extension) to be analyzed for forest monitoring.
  • date: A string representing the acquisition date of the image.
  • aoi_mask: A geojson object containing the geographical boundary data for the AOI mask, used to focus the NDVI analysis and vegetation monitoring on the specified area.
  • storage: An object representing the storage system or service that provides methods for reading, creating, and saving raster images and other data types. It handles the access to the underlying data storage mechanisms, like file systems or databases.
  • prefix: A string representing a prefix for the name of all files and results that are generated in the process. By default is "".
  • names: A dictionary representing the names that can be given to each of the files and analytics resulting from the process. By default is {}.

Returns: The function does not explicitly return a value; instead, it saves the output raster images and JSON tables representing the different processing steps and the final vegetation analysis into the provided storage system.

water_quality

The water_quality function analyzes satellite imagery of a specified area of interest (AOI) to assess different aspects of water quality. It computes indices related to water content, turbidity, and dissolved organic material. Additionally, the function creates median water masks, quantifies water extent, and produces colorized categorical maps for visualization. The results include spatial data files and analytical tables that summarize the water quality conditions in terms of area and percentage.

def water_quality(image_name, date, storage, prefix, names):

Parameters:

  • image_name: A string representing the name of the satellite image file to be processed for water quality analysis.
  • date: A string representing the acquisition date of the image.
  • storage: An object that encapsulates data access to the underlying storage system, providing methods for reading, creating, and saving spatial data files.
  • prefix: A string representing a prefix for the name of all files and results that are generated in the process. By default is "".
  • names: A dictionary representing the names that can be given to each of the files and analytics resulting from the process. By default is {}.

Returns: The function does not return values directly; instead, it produces output files, both raster datasets, and JSON tables, representing the different water quality indicators and stores them using the provided storage system.

Note: The code snippet for the function includes specific methods such as compute_median_water_mask, download_missing_images, and compute_doc which carry out various steps in the process flow to aid the main function completion. These helper methods feature their own sub-processes for manipulating satellite imagery and extracting desired outcomes.

Troubleshooting

If you encounter any issues during the installation of SPAI, please get in touch with use through our Discord server.

Back to top