Skip to content

sei-latam/WETSAT_v2

Repository files navigation

Typing SVG

Logo WetSAT-ML

WetSAT-ML Version 1.0

Wetlands flooding extent and trends using SATellite data and Machine Learning Version 1.0
Logo SEI

πŸ›°οΈ WetSAT-ML Version 1.0 Documentation

General Summary

WetSAT-ML (Wetlands flooding extent and trends using SATellite data and Machine Learning) version 1.0, It consists of an open-source algorithm integrated with platforms such as: Google Earth Engine, Google Colab, and Scikit Learn. The tool processes radar satellite data from the Sentinel-1 mission to generate wetland flooding extent maps, water permanence maps, and quantify key hydrological parameters, including flooded area time series, hydroperiods, and intra- and inter-annual wetland area trends. The algorithm will use machine learning models to characterize the scattering behavior of the radar signal for different wetland flooding conditions, enabling a pixel-level water detection in the satellite images.

Master Script Random Forest Code from Google Colab image

https://colab.research.google.com/github/sei-latam/WETSAT_v2/blob/main/2_Modelling_WETSAT_Google_Colab/Master_Random_Forest_WetSAT.ipynb

Master Script K-means Code from Google Colab image

https://colab.research.google.com/github/CarlosMendez1997Sei/WETSAT_v2/blob/main/2_Modelling_WETSAT_Google_Colab/Master_Kmeans.ipynb

User Script Random Forest Code from Google Colab image

https://colab.research.google.com/github/sei-latam/WETSAT_v2/blob/main/2_Modelling_WETSAT_Google_Colab/User_Version_Random_Forest_WetSAT.ipynb

User Script K-means Code from Google Colab image

https://colab.research.google.com/github/sei-latam/WETSAT_v2/blob/main/2_Modelling_WETSAT_Google_Colab/User_Version_Kmeans_WetSAT.ipynb

The tool WetSAT-ML allow users to:

  • Generate wetland flooding extent maps.
  • Produce water permanence maps.
  • Extract flooded area time series.
  • Quantify intra-annual and inter-annual wetland hydrological trends.

WetSAT-ML methodology workflow for generating wetland flooding extent and trends using Sentinel-1 data and machine learning.

Figure 1. WetSAT-ML methodology workflow for generating wetland flooding extent and trends using Sentinel-1 data and machine learning.

Repository Structure πŸ“

WETSAT_v2/
β”œβ”€β”€ 0_Original_Files/
β”‚   β”œβ”€β”€ aoi1/
β”‚   └── aoi2/
β”‚       β”œβ”€β”€ sigma_dB/
β”‚       β”‚   β”œβ”€β”€ VH/
β”‚       β”‚   β”œβ”€β”€ VV/
β”‚       β”‚   └── PR_index/
β”‚       └── points_AOI2_BDE.shp
β”œβ”€β”€ models/
└── README.md

(1.0) Installation of packages and libraries βš™οΈ

Static Badge image

###################################### Artificial Intelligence Frameworks #####################################################
!pip install scikit-learn
###################################### Data, Geoprocessing and Graphics libraries #####################################################
!pip install rasterio
!pip install matplotlib
!pip install numpy
!pip install contextily
!pip install geopandas

## Geoprocessing packages
import rasterio
from rasterio.features import rasterize
import numpy as np
import geopandas as gpd
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
import gc  # Garbage collector to free memory
import os
import contextily as ctx
from shapely.geometry import box
import seaborn as sns
import joblib
import urllib.request
import warnings
from google.colab import files
from google.colab import data_table

(2.0) πŸ—ΊοΈ Images preparation (VV,VH and PR)

Input Data:

  • VH and VV SAR images (.tif)
  • Compute PR Index
(PR = VH - VV)

(3.0) πŸ—ΊοΈ Labels and Marks preparation

Input Data:

  • Import shapefile points with labels and marks
  • Reproject shapefile to match raster CRS
  • Filter points within raster bounds
  • Extract pixel values at labeled points

(4.0) Connect Google Colab/GitHub

Option 1: Import manually Areas Of Interest (AOI) github

https://github.com/sei-latam/WETSAT_v2/tree/main/0_Original_Files/aoi1
https://github.com/sei-latam/WETSAT_v2/tree/main/0_Original_Files/aoi2

Option 2: Clone the repository of GitHub

HTTPS

https://github.com/sei-latam/WETSAT_v2.git

GitHub SSH

git@github.com:sei-latam/WETSAT_v2.git

GitHub CLI

gh repo clone sei-latam/WETSAT_v2

Static Badge scikit_learn

(5.0) Import the Random Forest Model and dependences of Machine Learning 🧠

from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report, confusion_matrix, accuracy_score
from sklearn.impute import SimpleImputer
from sklearn.multioutput import MultiOutputClassifier
from sklearn.preprocessing import LabelEncoder
from sklearn.exceptions import UndefinedMetricWarning
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.pipeline import Pipeline

(6.0) Prepare the Random Forest Model πŸ” 

  • Prepare Training Data (70%)
  • Prepare Validation Data (30%)
  • Store Data in pickle (.pkl) formats, for example ----> joblib.dump(le, "/models/label_encoder.pkl")
  • Display Data

7.0 and 8.0: Training Random Forest Model 🌲

  • Train a Random Forest classifier with hyperparameter tuning:
  • Save the best model in pickle (.pkl) format, for example ----> joblib.dump(best_model, "/models/modelo_random_forest.pkl")
param_grid = {
    'n_estimators': [100, 200],
    'max_depth': [10, 20, None],
    'min_samples_split': [2, 5],
    'min_samples_leaf': [1, 2],
    'max_features': ['sqrt', 'log2']
}

9.0 Evaluate the Random Forest Model πŸ“Š

  • Accuracy score
  • Best hyperparameters
  • Confusion matrix
  • Classification report

10.0 Classification Wetlands and Maps πŸ§ͺ (you can to classify actual or news AOI's)

  • Import the pickle files previously created (model, encoders and labels)
  • Add news images (VV, VH and PR), if you don't have PR index, you can to recalculate the PR index following the equation (PR = VH - VV)
  • Upload the model and make predictions

11.0 and 12.0 Transform predicted values (categorical and numerical) to legend and export images

  • Use encoder label to transform values (optional) πŸ“Œ
  • Export to raster (.tif) images in AOI selected, for example -----> Classification_labels_XX.tif
  • Open the raster images predicted in Open Source GIS, for example QGIS

Versions and releases

Version in R

https://github.com/sei-latam/WETSAT

Version 1.0

https://github.com/sei-latam/WETSAT_v2

Citations and References

For WetSAT-ML citations and references, please use the following structure:

Palomino-Ángel, S., Méndez, C., Zamora, D., Santos, T., Prasad, S., and Piman, T. (2025). WetSAT-ML: Wetlands flooding extent and trends using SATellite data and Machine Learning (Version 1.0) [Data System]. Stockholm Environment Institute (SEI). https://github.com/sei-latam/WETSAT_v2.

License

GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007

Copyright (C) 2007 Free Software Foundation, Inc. https://fsf.org/ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

Releases

No releases published

Packages

 
 
 

Contributors

Languages