fabiohochleitner / POS2IDON

Pipeline for ocean feature detection with Sentinel 2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

POS2IDON

Pipeline for Ocean Features Detection with Sentinel-2.

Objective

The objective of this work is to foster the development of a tool for monitoring ocean features, particularly floating plastic accumulations, using Sentinel-2 satellite imagery. By providing the source code, the vision is to provide a transparent easy-to-examine code that can be decomposed in several modules, and in this way stimulate improvements and new implementations from the scientific community to reach the ultimate goal of tracking floating plastic in an operational manner from satellite data.

Workflow

In this repository we propose an open-policy data pipeline framework for ocean features detection (e.g. floating plastic patches, foam, floating macroalgae, turbid water and clear water) using Sentinel-2 satellite imagery and machine learning methods. The presented workflow consists of three main steps:

  1. search and download Level-1C Sentinel-2 imagery from Copernicus Open Access Hub, Google Cloud Storage or the new Copernicus Data Space Ecosystem for a given region of interest and specified time period.

  2. image pre-processing: application of ACOLITE atmospheric correction module to obtain Rayleigh-corrected reflectances and surface reflectances, application of a land mask based on ESA World Cover 2021, application of a cloud mask computed with Sentinel Hub's cloud detector for Sentinel-2 imagery, application of “marine clear water” mask (NDWI-based, or a NIR-reflectance based thresholding).

  3. pixel-based classification with machine learning methods on the downloaded set of Sentinel-2 images. The workflow supports three well-known machine learning algorithms (Random Forest, XGBoost and Unet) trained with spectral signatures, as well as spectral indices (e.g., NDVI - Normalized Difference Vegetation Index, FAI - Floating Algae Index, FDI - Floating Debris Index). As additional option, the classification step using Random Forest trained models, can be computed also with Julia programming language. Outputs include the classification maps and classification probability maps, for the chosen region and time period. For large regions of interest, one has the option to split the image for classification and then mosaic.

Dependencies

Python

POS2IDON is coded in Python 3.9. In the terminal, create a Python environment using conda:

conda create -n pos2idon-env python=3.9

activate it:

conda activate pos2idon-env

and install libraries in the following order(can take up to 5 minutes):

(macOS Ventura):

conda install -c pytorch pytorch=1.13.1 torchvision=0.14.1 torchaudio=0.13.1
conda install -c conda-forge gdal=3.5.0 geopandas=0.11.1 lightgbm=3.3.2
pip install python-dotenv==0.20.0 sentinelsat==1.1.1 zipfile36==0.1.3 netCDF4==1.5.8 pyproj==3.3.1 scikit-image==0.19.2 pyhdf==0.10.5 --extra-index-url https://artifactory.vgt.vito.be/api/pypi/python-packages/simple terracatalogueclient==0.1.11 matplotlib==3.5.2 pandas==1.4.3 scikit-learn==1.1.1 ubelt==1.1.2 rasterio==1.3.0.post1 hummingbird-ml==0.4.5 julia==0.6.0 xgboost==1.7.3 s2cloudless==1.7.0

(Windows):

conda install -c conda-forge gdal=3.5.0 geopandas=0.11.1 lightgbm=3.3.2
pip install python-dotenv==0.20.0 sentinelsat==1.1.1 zipfile36==0.1.3 netCDF4==1.5.8 pyproj==3.3.1 scikit-image==0.19.2 pyhdf==0.10.5 --extra-index-url https://artifactory.vgt.vito.be/api/pypi/python-packages/simple terracatalogueclient==0.1.11 matplotlib==3.5.2 pandas==1.4.3 scikit-learn==1.1.1 ubelt==1.1.2 rasterio==1.3.0.post1 hummingbird-ml==0.4.5 julia==0.6.0 xgboost==1.7.3 s2cloudless==1.7.0
conda install -c pytorch pytorch=1.13.1 torchvision=0.14.1 torchaudio=0.13.1

Tested with Conda version 4.12.0 and Pip version 23.0.1.

Julia (testing phase - can be ignored)

To run the classification step using Julia programming language is necessary to install locally a version julia (1.8.3 tested) with the following packages: DataFrames.jl, DecisionTree.jl ,JLD2.jl,Pandas.jl PyCall.

This has been tested successfully on Windows (11) machine in VSCode. The Julia function is contained in modules/Classification.jl and is called using PyJulia as python interface to julia. To correctly set-up the interfacing of Python with Julia this link can be useful.

Configurations

If the cloning does not start automatically or if the repositories were corrupted during cloning, you can manually download them using the previous links.

The first time you run FeLS it will download a csv table, this process may take a few minutes.

Settings and Usage

Open configs/User_Inputs.py and follow the descriptions to set up wanted workflow options, insert region of interest and sensing period, select download service, define masking and classification options. Execute the script workflow.py to run the workflow.

Example

To test the classification workflow we provide a random forest model based on MARIDA spectral signatures library and trained as described in Kikaki et al., 2022. You can download the model folder using this link and place it in configs/MLmodels. By default the User_Inputs.py is configured to perform a classification on a plastic debris event case study that occurred in the Gulf of Honduras on 18th September 2020.

Visualization with QGIS, color palette provided inside configs/QGIScolorpalettes.

About

Pipeline for ocean feature detection with Sentinel 2

License:MIT License


Languages

Language:Python 99.5%Language:Julia 0.5%