TFG

Vegetation-focused ST-Cube Segmentation

Spatiotemporal trace segmentation for vegetation analysis using NDVI clustering with spatial constraints.

University thesis project for vegetation analysis using satellite time series data.

Overview

This package segments satellite NDVI time series into spatially and temporally coherent clusters representing vegetation patches with similar NDVI dynamics and spatial proximity. Uses DBSCAN clustering for robust density-based segmentation that automatically determines the number of clusters.

Example Interactive Visualization

How It Works

  1. Data Loading: Loads NetCDF files containing NDVI time series, with optional municipality filtering
  2. Vegetation Filtering: Selects traces with mean NDVI above threshold and sufficient temporal variance
  3. Clustering:
    • Combines NDVI time series and spatial coordinates, weighted by temporal_weight and spatial_weight
    • Uses DBSCAN to cluster traces into NDVI-similar and spatially close groups
    • Number of clusters determined automatically by DBSCAN parameters (eps and min_pts)
  4. Spatial Constraints: Ensures clusters remain spatially coherent within max_spatial_distance
  5. Export & Visualization: Results exported as JSON with static (Matplotlib) and interactive (Plotly) visualizations

Clustering Algorithm (DBSCAN)

The core segmentation uses DBSCAN clustering on combined NDVI and spatial features:

  1. Feature Construction: Each trace gets a feature vector combining NDVI time series and spatial coordinates (x, y)
  2. DBSCAN Clustering:
    • Density-based clustering that groups traces based on feature similarity and density
    • Automatically determines the number of clusters based on data density
    • Can identify and filter out noise points (outliers)
    • Controlled by eps (maximum distance between neighbors) and min_pts (minimum points to form cluster)
  3. Parameters: Cluster formation controlled by eps and min_pts, with spatial coherence enforced via max_spatial_distance

DBSCAN is robust to noise and can find clusters of varying shapes and sizes, making it well-suited for irregular vegetation patterns.

Key Parameters

Configure in segment_config.yaml:

Segmentation Parameters

| Parameter | Description | |———–|————-| | min_cluster_size | Minimum traces for valid cluster | | max_spatial_distance | Maximum trace distance for spatial clustering | | min_vegetation_ndvi | Minimum NDVI threshold for vegetation | | ndvi_variance_threshold | Minimum NDVI variance to include trace |

Clustering Parameters

| Parameter | Description | |———–|————-| | eps | DBSCAN Epsilon: maximum distance between samples to be neighbors | | min_pts | DBSCAN min_pts: minimum traces in neighborhood to form cluster | | temporal_weight | Weight for temporal vs spatial features (0-1) | | spatial_weight | Weight for spatial coordinates in feature space |

Visualization Parameters

| Parameter | Description | |———–|————-| | enable_3d_visualization | Enable/disable 3D interactive visualization creation | | enable_static_visualization | Enable/disable static 2D visualization creation |

File Structure

analysis/
├── __init__.py
├── visualization/
│   ├── __init__.py
│   ├── visualization_2d.py    # Matplotlib static plots
│   ├── visualization_3d.py    # Plotly interactive 3D plots
│   └── common.py              # Common visualization utilities
├── config_loader.py           # YAML config loader
├── json_exporter.py           # JSON export utilities
├── segmentation_main.py       # Main pipeline entry point (contains VegetationSegmentationParameters)
├── segment_config.yaml        # Main YAML config
└── README.md

Output Structure

Parameter Tuning Tips

Segmentation Parameters:

Clustering Parameters:

Data Requirements

NetCDF file (created using processing/create_mdim_raster.py) with: