Quantamaster/Earth-Observation

This project provides a complete, reproducible workflow for automated land cover classification using Sentinel-2 image patches and ESA WorldCover data. The pipeline enables extraction, labeling, and supervised modeling of large geospatial chip collections, supporting quantitative environmental audit and analysis.

โ˜… 0Forks 0PythonGitHub โ†—Compare
cnn-for-visual-recognitioncnn-modelcsv-filesdata-visualisationgis-developmentpythonsentinel-2

README

๐ŸŒ Earth Observation Land Cover Classification Pipeline

AI-Based Geospatial Audit of the Delhi Airshed

Python PyTorch Satellite Geospatial License


Space for climate and water

๐Ÿ“š Table of Contents


๐Ÿ“Œ Overview

This repository presents a reproducible Earth Observation (EO) and Deep Learning pipeline for automated land-cover classification using Sentinel-2 RGB image patches and ESA WorldCover 2021 data.

The system enables:

  • Automated geospatial data filtering
  • Raster-based ground-truth label generation
  • Supervised CNN training using ResNet-18
  • Quantitative land-use and environmental analysis

The project is framed as an AI-based Geospatial Audit of the Delhi Airshed, suitable for research labs, environmental agencies, and policy analytics.


๐Ÿ›ฐ๏ธ Project Context

This work demonstrates how satellite imagery + deep learning can be leveraged for urban land-use monitoring and environmental auditing.

Data Sources

  • Sentinel-2 (10m resolution RGB imagery)
  • ESA WorldCover 2021 land-cover raster
  • Delhi-NCR administrative boundary (EPSG:4326)

๐Ÿง  System Architecture


โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Delhi-NCR AOI (GeoJSON)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Spatial Grid (60ร—60 km)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Sentinel-2 RGB Image Chips   โ”‚
โ”‚  (128ร—128 @ 10m resolution)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ ESA WorldCover Raster (10m)  โ”‚
โ”‚  โ†’ Mode-based Labeling       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Clean Labeled Dataset (CSV)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ ResNet-18 CNN (PyTorch)      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Metrics: Accuracy, F1, CM    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ Directory Structure

/Earth_Observation_Pipeline/
โ”‚
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ delhi_ncr_region.geojson
โ”‚   โ”œโ”€โ”€ delhi_ncr_grid.geojson
โ”‚   โ”œโ”€โ”€ worldcover_bbox_delhi_ncr_2021.tif
โ”‚   โ”œโ”€โ”€ rgb/                          # Sentinel-2 image patches (128ร—128)
โ”‚   โ”œโ”€โ”€ image_coords.csv
โ”‚   โ”œโ”€โ”€ imgs_within_grid.csv
โ”‚   โ””โ”€โ”€ labelled_images_clean.csv
โ”‚
โ”œโ”€โ”€ 01_grid_visualization.py
โ”œโ”€โ”€ 02_label_extract_assignment.py
โ”œโ”€โ”€ 03_train_test_split.py
โ”œโ”€โ”€ 04_cnn_train_eval.py
โ”‚
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ README.md

๐Ÿ“ฆ Dataset

Kaggle Dataset (Required): https://www.kaggle.com/datasets/rishabhsnip/earth-observation-delhi-airshed

Includes:

  • Sentinel-2 RGB image patches
  • Delhi-NCR shapefiles
  • Image coordinate metadata

๐Ÿ” Pipeline Breakdown

Phase 1: Spatial Reasoning & Filtering

  • Define AOI using Delhi-NCR boundary
  • Generate a uniform 60 ร— 60 km grid
  • Filter Sentinel-2 images by grid intersection

Script: 01_grid_visualization.py


Phase 2: Label Construction

  • Extract raster patches from ESA WorldCover
  • Assign land-cover class using mode-based sampling
  • Handle missing data and edge effects

Script: 02_label_extract_assignment.py


Phase 3: Dataset Cleaning & Split

  • Remove invalid labels
  • Perform stratified train-test split
  • Analyze class distribution

Script: 03_train_test_split.py


Phase 4: CNN Training & Evaluation

  • CNN: ResNet-18
  • Input: Sentinel-2 RGB chips
  • Metrics: Accuracy, F1 Score, Confusion Matrix

Script: 04_cnn_train_eval.py


๐Ÿ“Š Results & Metrics

(Representative โ€“ depends on training run)

  • Overall Accuracy: ~75โ€“85%
  • Macro F1 Score: ~0.72โ€“0.82
  • Strong Performance: Urban, Vegetation, Water
  • Challenges: Mixed land-cover and boundary regions

Outputs

  • Confusion Matrix
  • Class-wise F1 Scores
  • Correct vs Incorrect Prediction Visualizations

๐Ÿง  Model Details

  • Architecture: ResNet-18
  • Framework: PyTorch
  • Loss Function: Cross-Entropy
  • Evaluation Metrics: Accuracy, F1 Score

โš™๏ธ Technical Requirements

Python

  • Python 3.8+

Dependencies

pip install geopandas numpy pandas rasterio shapely scipy \
            matplotlib seaborn scikit-learn \
            torch torchvision torchmetrics \
            geemap

๐Ÿš€ Usage

1๏ธโƒฃ Grid Generation

python 01_grid_visualization.py

2๏ธโƒฃ Label Assignment

python 02_label_extract_assignment.py

3๏ธโƒฃ Train/Test Split

python 03_train_test_split.py

4๏ธโƒฃ Model Training

python 04_cnn_train_eval.py

๐Ÿงพ Data Format

labelled_images_clean.csv

| filename | lat | lon | label | class_str |


๐Ÿ› ๏ธ Troubleshooting

  • Ensure all data paths are correct
  • Run scripts in order
  • Verify image presence in rgb/

โœ… Best Practices

  • Preserve intermediate outputs
  • Validate class balance before training
  • Track experiment configurations

๐Ÿ“š Citation

Please cite the following if used in research or applications:

  • ESA WorldCover 2021
  • Copernicus Sentinel-2
  • Relevant geospatial data providers

โญ If this repository helps your work, consider starring it!

Contributors

Quantamaster

Issues