πŸ™οΈ UrbanGraphSAGE

March 6, 2026 Β· View on GitHub

Python PyTorch License CI

Building footprint extraction from Sentinel-2 satellite imagery using GraphSAGE β€” A case study on Algiers, Algeria.


Overview

UrbanGraphSAGE applies Graph Neural Networks to medium-resolution satellite imagery for urban building extraction. Instead of treating pixels independently, we construct superpixel graphs that capture spatial relationships, enabling the model to leverage neighborhood context for superior segmentation.

The Approach

graph LR
    A["πŸ›°οΈ Sentinel-2<br/>13 bands"] --> B["πŸ”² SLIC<br/>Superpixels"]
    B --> C["πŸ“Š Feature<br/>Extraction"]
    C --> D["πŸ”— Graph<br/>Construction"]
    D --> E["🧠 GraphSAGE<br/>Message Passing"]
    E --> F["πŸ—οΈ Node<br/>Classification"]
    F --> G["πŸ—ΊοΈ Building<br/>Footprint Map"]
StageMethodDetails
PreprocessingSentinel-2 L2ACloud masking, tiling (256Γ—256), band normalization
SuperpixelsSLIC (scikit-image)~500 superpixels/tile, compactness=20
FeaturesSpectral indices13 bands + NDVI + NDWI + NDBI per superpixel
Graphk-NN adjacencyk=8, spatial + spectral similarity
ModelGraphSAGE (PyG)3 layers, mean aggregation, 256 hidden dim
LabelsOpenStreetMapBuilding polygons β†’ superpixel majority vote

Results

ModelF1-ScoreIoUParameters
U-Net0.810.6931.0M
DeepLabv3+0.830.7241.0M
SegFormer-B20.850.7427.5M
UrbanGraphSAGE0.880.7912.3M

Installation

git clone https://github.com/OMUZ9924/UrbanGraphSAGE.git
cd UrbanGraphSAGE
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt

Quick Start

# Preprocess Sentinel-2 tiles into superpixel graphs
python -m src.preprocessing --input data/raw/ --output data/processed/

# Train GraphSAGE model
python -m src.train --config configs/default.yaml

# Run inference
python -m src.predict --checkpoint checkpoints/best.pt --input data/processed/test/

Project Structure

UrbanGraphSAGE/
β”œβ”€β”€ configs/default.yaml
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ preprocessing.py    # Sentinel-2 β†’ superpixel graph pipeline
β”‚   β”œβ”€β”€ graph_construction.py # Graph building from superpixels
β”‚   β”œβ”€β”€ model.py            # GraphSAGE architecture
β”‚   β”œβ”€β”€ train.py            # Training loop with validation
β”‚   β”œβ”€β”€ predict.py          # Inference and evaluation
β”‚   └── utils.py            # Metrics, visualization, seed
β”œβ”€β”€ tests/
β”œβ”€β”€ notebooks/
β”œβ”€β”€ .github/workflows/ci.yml
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ requirements.txt
└── README.md

Citation

@thesis{arbouz2025urbangraphsage,
  title   = {Graph Neural Networks and Deep Learning for Large-Scale Remote Sensing},
  author  = {Arbouz, Maamar},
  year    = {2025},
  school  = {University Djilali Bounaama, Khemis Miliana}
}

License

MIT β€” see LICENSE for details.


⭐ Star this repo if you find it useful!