Applications

This section lists some example applications of PyEO using the ready made scripts below.

The following scripts can all be run from the pyeo/bin folder after installation, or from their subfolders in pyeo/apps.

Run ACD National

An application that runs the raster and vector pipeline for all tiles intersecting with a Region of Interest.

The application runs using an initialisation file, which provides all the parameters PyEO needs to make decisions. See SEPAL pipeline training notebook within the notebooks folder on the GitHub Repository for an explanation of the initialisation file.

The raster pipeline, depending on True/False parameters provided in the initialisation file, performs the following:

  • Takes a Region of Interest (ROI) and calculates which Sentinel-2 (S2) tiles overlap with the ROI.

  • Builds a Baseline Composite to compare land cover changes against, by downloading S2 images and calculating the median of these images.

  • Downloads images over the Change Period

  • Classifies the Composite and the Change images using a classifier in ./models/

  • Calculates the change between the from classes and the to classes, for each classified image. This could be changes from forest to bare soil.

  • Creates a Change Report describing the consistency of the class changes, highlighting the changes that PyEO is confident.

The vector pipline, depending on the True/False parameters provided in the initialisation file, performs the following:

  • Vectorises the Change Report, removing any changes observed outside of the ROI.

  • Performs Zonal Statistics on the change polygons.

  • Filters the change polygons based on Counties of Interest.

Example call:

$python pyeo/run_acd_national.py path/to/pyeo_linux.ini

path/to/pyeo_linux.ini needs to be an absolute path, and works for all the OS .ini files e.g. pyeo_windows.ini , pyeo_sepal.ini .

Image Comparison

An application for applying a pickled scikit-learn model to two contiguous raster images.

Example call:

$image_comparison image_1.tif image_2.tif model.pkl class_map.tif

Simple S2 Change Detection

A change detection script that downloads, stacks and classifies a set of 10m sentinel 2 images.

When run, this script will download every S2 image in the aoi (defined by the geojson at aoi_path) between the two dates that meets the specified cloud cover range. It will use the sen2cor distribution specified in the .ini file to atmospherically correct the data to L2A, merge each set of 10m bands into a single geotiff, stack the images into pairs based on the algorithm in create_new_stacks and classify those images using a scikit-learn model

To use this script, fill out the [sent_2], [forest_sentinel] and [sen2cor] sections of the configuration file change_detection.ini, then run

$ python pyeo/apps/change_detection/simple_s2_change_detection.py --conf /path/to/change_detection.ini

Produces two directories of un-mosaiced imagery; one of classified images and one of class probabilites

Filter By Class Map

Filters every pixel in input_image that is not one of filter_classes.

Usage:

$ filter_by_class_map my_image.tif my_class_map.tif my_output_image.tif useful_class_1 useful_class_2

This will create an image, my_output_image.tif, that contains only the pixels from my_image.tif that are labelled as useful_class_1 and useful_class_2 in my_class_map.tif