ποΈ UrbanGraphSAGE
March 6, 2026 Β· View on GitHub
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"]
| Stage | Method | Details |
|---|---|---|
| Preprocessing | Sentinel-2 L2A | Cloud masking, tiling (256Γ256), band normalization |
| Superpixels | SLIC (scikit-image) | ~500 superpixels/tile, compactness=20 |
| Features | Spectral indices | 13 bands + NDVI + NDWI + NDBI per superpixel |
| Graph | k-NN adjacency | k=8, spatial + spectral similarity |
| Model | GraphSAGE (PyG) | 3 layers, mean aggregation, 256 hidden dim |
| Labels | OpenStreetMap | Building polygons β superpixel majority vote |
Results
| Model | F1-Score | IoU | Parameters |
|---|---|---|---|
| U-Net | 0.81 | 0.69 | 31.0M |
| DeepLabv3+ | 0.83 | 0.72 | 41.0M |
| SegFormer-B2 | 0.85 | 0.74 | 27.5M |
| UrbanGraphSAGE | 0.88 | 0.79 | 12.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!