terravision / README.md
prateeksharmacoder's picture
Update TerraVision application and documentation
4b76f6f
|
Raw
History Blame Contribute Delete
15.2 kB

๐ŸŒ TerraVision

Sharper Earth. Brighter Decisions.

TerraVision is a GIS-based satellite imagery analysis platform that uses Sentinel-2 satellite data and the official ESA OpenSR LDSR-S2 + SEN2SR super-resolution pipeline to generate model-based 2.5 m resolution imagery from freely available Sentinel-2 data.

The platform combines satellite image super-resolution, geospatial processing, spectral analysis, visualization, and GeoTIFF export into a single web-based workflow.


๐Ÿš€ Overview

Sentinel-2 provides freely available multispectral imagery, but its spatial resolution can be limiting for detailed geospatial analysis.

TerraVision addresses this challenge by:

  1. Selecting a location using latitude/longitude or an interactive map.
  2. Selecting a date range for Sentinel-2 imagery.
  3. Retrieving Sentinel-2 L2A data.
  4. Applying the ESA LDSR-S2 + SEN2SR super-resolution pipeline.
  5. Generating a model-based 2.5 m resolution, 10-band output.
  6. Producing multiple GIS analysis layers.
  7. Providing an original-vs-super-resolved comparison.
  8. Exporting georeferenced GeoTIFF files and a ZIP containing all outputs.

Important: The 2.5 m imagery generated by TerraVision is a model-based reconstruction. It is not native 2.5 m satellite observation.


โœจ Key Features

๐Ÿ›ฐ๏ธ Sentinel-2 Data

  • Sentinel-2 L2A imagery
  • 10 spectral bands
  • User-defined geographical location
  • User-defined date range

๐Ÿ”ฌ AI-Based Super Resolution

  • ESA OpenSR LDSR-S2 + SEN2SR
  • 10 m input
  • Model-generated 2.5 m output
  • 4ร— spatial upscaling
  • 10-band super-resolved output

๐Ÿ—บ๏ธ GIS Visualization

TerraVision generates:

  • Super-Resolved RGB
  • Original Sentinel-2 RGB
  • False Color / Infrared
  • SWIR Composite
  • NDVI
  • NDWI
  • NDBI
  • NBR
  • LDSR-S2 Uncertainty

๐Ÿ“Š Image Comparison

An interactive before/after comparison allows users to visually compare:

Original Sentinel-2 โ†’ Super-Resolved Output

๐Ÿ’พ Geospatial Export

Users can download:

  • Individual GeoTIFF layers
  • Complete ZIP package containing all generated layers

All exported layers preserve their geospatial reference information.


๐Ÿง  Super-Resolution Pipeline

TerraVision uses the official ESA OpenSR approach combining:

Sentinel-2 L2A
      โ”‚
      โ–ผ
Data Retrieval
      โ”‚
      โ–ผ
10-band Sentinel-2 Input
      โ”‚
      โ–ผ
LDSR-S2 + SEN2SR
      โ”‚
      โ–ผ
2.5 m Super-Resolved Output
      โ”‚
      โ”œโ”€โ”€ B02
      โ”œโ”€โ”€ B03
      โ”œโ”€โ”€ B04
      โ”œโ”€โ”€ B05
      โ”œโ”€โ”€ B06
      โ”œโ”€โ”€ B07
      โ”œโ”€โ”€ B08
      โ”œโ”€โ”€ B8A
      โ”œโ”€โ”€ B11
      โ””โ”€โ”€ B12
      โ”‚
      โ–ผ
GIS Analysis Layers

The pipeline combines the strengths of:

LDSR-S2

Latent diffusion super-resolution for Sentinel-2 RGB-NIR information.

SEN2SR

Super-resolution processing for the additional Sentinel-2 spectral bands.

Together, they provide the 10-band super-resolved output used by TerraVision.


๐Ÿ›ฐ๏ธ Sentinel-2 Bands

Band Description Resolution
B02 Blue 10 m
B03 Green 10 m
B04 Red 10 m
B05 Vegetation Red Edge 20 m
B06 Vegetation Red Edge 20 m
B07 Vegetation Red Edge 20 m
B08 NIR 10 m
B8A Narrow NIR 20 m
B11 SWIR 1 20 m
B12 SWIR 2 20 m

The super-resolution pipeline produces these bands at the model-generated 2.5 m output scale.


๐Ÿ“Š Spectral Analysis

TerraVision converts the super-resolved bands into several commonly used remote-sensing indices.

๐ŸŒฑ NDVI

Normalized Difference Vegetation Index

NDVI = (B08 - B04) / (B08 + B04)

Used to analyze vegetation density and vegetation condition.


๐Ÿ’ง NDWI

TerraVision uses the Green-NIR formulation:

NDWI = (B03 - B08) / (B03 + B08)

Used to highlight water-related features.


๐Ÿ™๏ธ NDBI

Normalized Difference Built-up Index

NDBI = (B11 - B08) / (B11 + B08)

Used for identifying built-up and urban areas.


๐Ÿ”ฅ NBR

Normalized Burn Ratio

NBR = (B08 - B12) / (B08 + B12)

Useful for analyzing burn-affected areas and vegetation disturbance.


๐ŸŽจ Visualization Layers

TerraVision provides several visualization products.

RGB Composite

R = B04
G = B03
B = B02

Provides a natural-color representation.

False Color Composite

R = B08
G = B04
B = B03

Useful for vegetation analysis.

SWIR Composite

R = B12
G = B11
B = B04

Useful for analyzing moisture, soil, built-up areas and burned regions.


๐Ÿ“ˆ Uncertainty Map

TerraVision also exposes the uncertainty estimation available from the underlying LDSR-S2 RGB-NIR component.

The uncertainty map highlights areas where the super-resolution model has greater variation across generated samples.

Dark  โ†’ Lower estimated uncertainty
Bright โ†’ Higher estimated uncertainty

Important limitation

This should not be interpreted as a calibrated confidence score for the complete 10-band output.

The current implementation calculates uncertainty from the underlying 4-band LDSR-S2 RGB-NIR model.


๐Ÿ—บ๏ธ TerraVision Workflow

User
 โ”‚
 โ”œโ”€โ”€ Select Location
 โ”‚       โ””โ”€โ”€ Latitude / Longitude
 โ”‚
 โ”œโ”€โ”€ Select Date Range
 โ”‚
 โ–ผ
Sentinel-2 L2A Data
 โ”‚
 โ–ผ
Preprocessing
 โ”‚
 โ–ผ
ESA LDSR-S2 + SEN2SR
 โ”‚
 โ–ผ
2.5 m Super-Resolved Imagery
 โ”‚
 โ”œโ”€โ”€ RGB
 โ”œโ”€โ”€ False Color
 โ”œโ”€โ”€ SWIR
 โ”œโ”€โ”€ NDVI
 โ”œโ”€โ”€ NDWI
 โ”œโ”€โ”€ NDBI
 โ”œโ”€โ”€ NBR
 โ””โ”€โ”€ Uncertainty
 โ”‚
 โ–ผ
Interactive Visualization
 โ”‚
 โ–ผ
GeoTIFF / ZIP Export

๐Ÿ› ๏ธ Technology Stack

Frontend / UI

  • Python
  • Gradio
  • Interactive visualization
  • Image comparison slider
  • GIS map integration

Machine Learning

  • PyTorch
  • ESA OpenSR
  • LDSR-S2
  • SEN2SR

Geospatial Processing

  • Rasterio
  • Rioxarray
  • GeoPandas
  • PyProj
  • Xarray
  • Dask
  • Cubo

Satellite Data

  • Sentinel-2 L2A
  • STAC-based data access

Model / Data Management

  • MLSTAC
  • Hugging Face ecosystem

Deployment

  • Hugging Face Spaces
  • Gradio
  • ZeroGPU-compatible architecture

๐Ÿ“ฆ Installation

Clone the repository:

git clone https://github.com/prateeksharmacoder-sys/satellite-LDRS-SEN2SR.git
cd TerraVision

Create a virtual environment:

python -m venv venv

Activate it.

Windows

venv\Scripts\activate

Linux / macOS

source venv/bin/activate

Install dependencies:

pip install -r requirements.txt

โ–ถ๏ธ Running the Application

Run:

python app.py

The Gradio interface will provide a local web address.

For development, the application can also be launched with:

demo.launch()

๐Ÿ“ Project Structure

TerraVision/
โ”‚
โ”œโ”€โ”€ app.py
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ README.md
โ”‚
โ”œโ”€โ”€ models/
โ”‚   โ””โ”€โ”€ model configuration / model assets
โ”‚
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ preprocessing.py
โ”‚   โ”œโ”€โ”€ visualization.py
โ”‚   โ”œโ”€โ”€ geotiff.py
โ”‚   โ””โ”€โ”€ analysis.py
โ”‚
โ”œโ”€โ”€ outputs/
โ”‚   โ””โ”€โ”€ generated products
โ”‚
โ””โ”€โ”€ assets/
    โ””โ”€โ”€ UI images / project assets

The exact structure may vary depending on the final deployment version.


๐Ÿ”ฌ Technical Implementation

1. Data Retrieval

TerraVision retrieves Sentinel-2 L2A imagery using a STAC-based workflow.

The application requests:

B02
B03
B04
B05
B06
B07
B08
B8A
B11
B12

2. Preprocessing

Sentinel-2 reflectance values are converted into normalized floating-point values before inference.

low_resolution = low_resolution / 10000

3. Super Resolution

The combined model is loaded and executed using SEN2SR:

super_resolution = sen2sr.predict_large(
    model=model,
    X=low_resolution,
    overlap=16
)

The model converts:

10 ร— 128 ร— 128

into approximately:

10 ร— 512 ร— 512

4. Spectral Products

The generated bands are used to calculate spectral indices such as:

NDVI = (B08 - B04) / (B08 + B04)
NDWI = (B03 - B08) / (B03 + B08)
NDBI = (B11 - B08) / (B11 + B08)
NBR  = (B08 - B12) / (B08 + B12)

5. Geospatial Export

Generated products are exported as GeoTIFF files while preserving:

  • CRS
  • Spatial transform
  • Resolution
  • Geographic bounds

The prototype output was verified at:

Resolution: 2.5 m
CRS: EPSG:32630
Output size: 512 ร— 512

The exact CRS changes according to the selected geographic location.


๐Ÿ“ฅ Output Files

A typical output package contains:

terravision_layers.zip
โ”‚
โ”œโ”€โ”€ sr_rgb.tif
โ”œโ”€โ”€ false_color.tif
โ”œโ”€โ”€ swir.tif
โ”œโ”€โ”€ ndvi.tif
โ”œโ”€โ”€ ndwi.tif
โ”œโ”€โ”€ ndbi.tif
โ”œโ”€โ”€ nbr.tif
โ””โ”€โ”€ uncertainty.tif

โšก Performance

The current prototype has been successfully tested end-to-end with:

Sentinel-2 input:       10 ร— 128 ร— 128
Super-resolution:       10 ร— 512 ร— 512
Output resolution:      2.5 m
Analysis layers:        8
GeoTIFF export:         Successful
ZIP generation:         Successful

The super-resolution inference is the computationally expensive part of the pipeline.

Uncertainty estimation requires additional inference and is therefore treated as an optional computational component for deployment optimization.


โš ๏ธ Limitations

TerraVision currently has several limitations.

1. Model-Based Resolution

The 2.5 m output is reconstructed by an AI model and is not equivalent to native 2.5 m satellite imagery.

2. Reconstruction Errors

Super-resolution models can introduce artifacts or reconstruct details that are not directly observed in the original imagery.

3. Cloud and Atmospheric Effects

Clouds, haze and poor-quality Sentinel-2 observations can affect the output.

4. Scientific Validation

The current prototype has been technically validated for:

  • successful model inference
  • correct output dimensions
  • spectral layer generation
  • GeoTIFF generation
  • geospatial referencing

A comprehensive validation against independent high-resolution reference imagery using metrics such as PSNR, SSIM and spectral consistency remains future work.

5. Uncertainty

The current uncertainty output represents the LDSR-S2 RGB-NIR component rather than a calibrated uncertainty estimate for all 10 bands.

6. Temporal Analysis

Change detection such as dNBR requires pre-event and post-event imagery and is not part of the current single-image workflow.


๐Ÿ”ฎ Future Scope

Potential future improvements include:

  • Multi-date satellite analysis
  • Automated change detection
  • dNDVI / dNBR analysis
  • Cloud masking
  • Larger-area processing
  • Batch processing
  • More advanced GIS layers
  • Scientific validation using higher-resolution reference imagery
  • Performance optimization
  • GPU acceleration
  • Caching of satellite data
  • Production-scale deployment
  • User accounts and project history
  • Export to additional GIS formats

๐ŸŒ Deployment

TerraVision is designed to be deployed as a Gradio application.

The planned deployment architecture is:

User
  โ”‚
  โ–ผ
TerraVision Web Interface
  โ”‚
  โ–ผ
Gradio Application
  โ”‚
  โ”œโ”€โ”€ Satellite Data Retrieval
  โ”‚
  โ”œโ”€โ”€ GPU Inference
  โ”‚
  โ”œโ”€โ”€ Spectral Analysis
  โ”‚
  โ””โ”€โ”€ GeoTIFF Generation
  โ”‚
  โ–ผ
Results + Downloads

The application can be adapted for GPU-backed deployment using Hugging Face Spaces ZeroGPU.


๐Ÿงช Validation Status

Component Status
Sentinel-2 data retrieval โœ… Tested
10-band input generation โœ… Tested
LDSR-S2 + SEN2SR inference โœ… Tested
2.5 m output generation โœ… Tested
RGB generation โœ… Tested
False Color โœ… Tested
SWIR โœ… Tested
NDVI โœ… Tested
NDWI โœ… Tested
NDBI โœ… Tested
NBR โœ… Tested
LDSR-S2 uncertainty โœ… Tested
GeoTIFF export โœ… Tested
Georeferencing โœ… Verified
ZIP export โœ… Tested
Interactive web UI โœ… Prototype
Scientific benchmark validation ๐Ÿ”„ Future work
Production-scale deployment ๐Ÿ”„ Planned

๐ŸŽฏ Use Cases

TerraVision can support exploratory analysis in areas such as:

  • ๐ŸŒฑ Vegetation monitoring
  • ๐Ÿ’ง Water-body analysis
  • ๐Ÿ™๏ธ Urban expansion studies
  • ๐Ÿ”ฅ Burn-area analysis
  • ๐ŸŒพ Agricultural monitoring
  • ๐Ÿ›ฐ๏ธ Remote-sensing research
  • ๐Ÿ—บ๏ธ GIS analysis
  • ๐ŸŒ Environmental monitoring

๐Ÿ“š Acknowledgements

TerraVision builds upon open-source satellite super-resolution research and software from the European Space Agency (ESA) OpenSR project, including LDSR-S2 and SEN2SR.

The project also uses open geospatial and satellite-data technologies including:

  • Sentinel-2
  • Cubo
  • MLSTAC
  • PyTorch
  • Rasterio
  • Xarray
  • Gradio

๐Ÿ“œ Disclaimer

TerraVision is a research and demonstration project.

The generated 2.5 m imagery should not automatically be treated as equivalent to native high-resolution satellite imagery. Results may contain model reconstruction artifacts and should be independently validated before being used for critical scientific, commercial, legal, or operational decisions.


๐Ÿ‘จโ€๐Ÿ’ป Project

TerraVision

Sharper Earth. Brighter Decisions.

Built as a geospatial AI project for exploring the potential of satellite-image super-resolution and GIS analysis.


โญ If you find TerraVision interesting

Consider giving the repository a โญ and exploring the implementation.


### Recommended GitHub repository files

For your current project, I would keep the repository clean like this:

```text
TerraVision/
โ”‚
โ”œโ”€โ”€ README.md              โ† this file
โ”œโ”€โ”€ app.py                 โ† main Gradio application
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ .gitignore
โ”‚
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ satellite.py
โ”‚   โ”œโ”€โ”€ analysis.py
โ”‚   โ”œโ”€โ”€ visualization.py
โ”‚   โ””โ”€โ”€ geotiff.py
โ”‚
โ””โ”€โ”€ assets/
    โ””โ”€โ”€ screenshots/

One important point: don't upload the ~1.4 GB model file directly into GitHub. Your code can download/load the model from its Hugging Face model repository at runtime.

If you want, I can also create the actual README.md file for you as a downloadable file, ready to put directly into your GitHub repository.