prs-eth / ukraine-damage-mapping-tool

An Open-Source Tool for Mapping War Destruction at Scale in Ukraine using Sentinel-1 Time Series

Repository from Github https://github.comprs-eth/ukraine-damage-mapping-toolRepository from Github https://github.comprs-eth/ukraine-damage-mapping-tool

An Open-Source Tool for Mapping War Destruction at Scale in Ukraine using Sentinel-1 Time Series

Olivier Dietrich*,1, Torben Peters1, Vivien Sainte Fare Garnot2, Valerie Sticher2, Thao Ton-That Whelan3, Konrad Schindler1, Jan Dirk Wegner2

1 ETH Zurich 2 University of Zurich 3 International Committee of the Red Cross

*Corresponding author: Olivier Dietrich

Paper Dashboard 1 Dashboard 2 Zenodo MIT License

Ukraine Damage Map

๐Ÿ‡บ๐Ÿ‡ฆ Results

The results, including heatmaps and building footprints, can be found here.

๐ŸŽฎ Dashboards

We provide two Google Earth Engine dashboards:

Screenshot Damage Mapping Tool
Damage Mapping Tool
Screenshot Results Explorer
Ukraine Damage Explorer

๐ŸŒฒ Repository Structure

notebooks/                     # Jupyter notebooks to reproduce results
  โ”œโ”€โ”€ classification.ipynb
  โ”œโ”€โ”€ country_stats.ipynb
  โ””โ”€โ”€ evaluation.ipynb

src/                            # Source code for data processing, model training, and inference
  โ”œโ”€โ”€ classification/           # Classification script to train and evaluate models
  โ”‚     โ”œโ”€โ”€ dataset.py
  โ”‚     โ”œโ”€โ”€ main.py
  โ”‚     โ”œโ”€โ”€ metrics.py
  โ”‚     โ”œโ”€โ”€ models.py
  โ”‚     โ”œโ”€โ”€ reducers.py
  โ”‚     โ””โ”€โ”€ utils.py
  โ”‚
  โ”œโ”€โ”€ data/                     # Scripts for data processing and handling
  โ”‚     โ”œโ”€โ”€ overture/
  โ”‚     โ”œโ”€โ”€ sentinel1/
  โ”‚     โ”œโ”€โ”€ sentinel2/
  โ”‚     โ”œโ”€โ”€ quadkeys.py
  โ”‚     โ”œโ”€โ”€ unosat.py
  โ”‚     โ””โ”€โ”€ utils.py
  โ”‚
  โ”œโ”€โ”€ inference/                # Script for inference over entire country
  โ”‚     โ”œโ”€โ”€ dense_inference.py
  โ”‚     โ””โ”€โ”€ full_ukraine.py
  โ”‚
  โ”œโ”€โ”€ postprocessing/           # Download from drive and postprocess results
  โ”‚     โ”œโ”€โ”€ drive_to_results.py
  โ”‚     โ””โ”€โ”€ utils.py
  โ”‚
  โ”œโ”€โ”€ utils/                    # Utils functions
  |     โ”œโ”€โ”€ gdrive.py
  |     โ”œโ”€โ”€ gee.py
  |     โ”œโ”€โ”€ geo.py
  |     โ””โ”€โ”€ time.py
  โ”‚
  โ”œโ”€โ”€ constants.py
  โ””โ”€โ”€ __init__.py

๐Ÿ› ๏ธ Setup

This was tested on Ubuntu 22.04 LTS with Python 3.12.7 and 64GB RAM

๐Ÿ‘ Clone the repository

git clone https://github.com/odietric/ukraine-mapping-tool.git
cd ukraine-mapping-tool

๐Ÿ Python Environment

To create the environment, run the following command:

conda create -p ./ukraine_env python=3.12 geopandas gdal -c conda-forge --strict-channel-priority --yes
conda activate ./ukraine_env
python -m pip install uv
python -m uv pip install -r requirements.txt

or simply:

make env

๐Ÿ’พ Data

All project data is publicly available:

  • UNOSAT

    Preprocessed UNOSAT labels and AOIs are stored in data/unosat_labels.geojson and data/unosat_aois.geojson, respectively.

  • Sentinel-1

    Sentinel-1 images are processed in the cloud via Google Earth Engine.

  • Overture Maps Building Footprints

    To obtain the preprocessed Overture Maps Building Footprints in Ukraine, you can either download the file ukraine_buildings.parquet from the link above and place it in the data/overture_buildings folder, or compute it yourself by running the following command:

    bash src/data/overture/download_and_preprocess.sh

๐Ÿ’ฝ Google Drive Access Configuration

To download the results from Google Drive, you need to configure the Google Drive API and add the files pydrive_settings.yaml and pydrive_credentials.json to the secrets folder.

  1. Create Google API Credentials:

    • Go to Google Cloud Console: API & Services > Credentials > Create Credentials > OAuth client ID > Desktop app.
  2. Download and Configure Credentials:

    • Download the .json credentials file.

    • Store the client_id and client_secret values from this file in pydrive_settings.yaml as follows:

      client_config_backend: 'settings'
      
      client_config:
        client_id: <your_client_id>
        client_secret: <your_client_secret>
      
      save_credentials: True
      save_credentials_backend: 'file'
      save_credentials_file: </path/to/project/>secrets/pydrive_credentials.json
      
      get_refresh_token: True
      oauth_scope:
        - "https://www.googleapis.com/auth/drive"
    • Replace <your_client_id> and <your_client_secret> with values from your credentials JSON file.

    • Replace /path/to/project/secrets/pydrive_credentials.json with the full path to the pydrive_credentials.json file within your project.\

    • The pydrive_credentials.json file will be automatically created upon the first authentication attempt.

  3. Example usage in code:

    from pydrive2.auth import GoogleAuth
    from pydrive2.drive import GoogleDrive
    from src.constants import SECRETS_PATH
    
    # Initialize authentication
    GoogleAuth.DEFAULT_SETTINGS["client_config_file"] = SECRETS_PATH / "pydrive_credentials.json"
    gauth = GoogleAuth(settings_file=SECRETS_PATH / "pydrive_settings.yaml")
    drive = GoogleDrive(gauth)

Citation

@article{dietrich2024ukraine,
  title={An Open-Source Tool for Mapping War Destruction at Scale in Ukraine using Sentinel-1 Time Series},
  author={Olivier Dietrich and Torben Peters and Vivien Sainte Fare Garnot and Valerie Sticher and Thao Ton-That Whelan and Konrad Schindler and Jan Dirk Wegner},
  journal={arXiv preprint arXiv:/2406.02506},
  year={2024},
  url={https://arxiv.org/abs/2406.02506},
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

An Open-Source Tool for Mapping War Destruction at Scale in Ukraine using Sentinel-1 Time Series

License:MIT License


Languages

Language:Jupyter Notebook 84.4%Language:Python 15.5%Language:Makefile 0.1%Language:Shell 0.0%