Spatiotemporal trace segmentation for vegetation analysis using NDVI clustering with spatial constraints.
University thesis project for vegetation analysis using satellite time series data.
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.
temporal_weight
and spatial_weight
eps
and min_pts
)max_spatial_distance
The core segmentation uses DBSCAN clustering on combined NDVI and spatial features:
eps
(maximum distance between neighbors) and min_pts
(minimum points to form cluster)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.
Configure in segment_config.yaml
:
| 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 |
| 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 |
| Parameter | Description |
|———–|————-|
| enable_3d_visualization
| Enable/disable 3D interactive visualization creation |
| enable_static_visualization
| Enable/disable static 2D visualization creation |
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
vegetation_clusters_<municipality>.json
Segmentation Parameters:
max_spatial_distance
: Higher values allow more spatial spread in post-processingmin_cluster_size
: Prevents tiny/noisy clusters through post-processingmin_vegetation_ndvi
: Threshold for initial vegetation trace selectionndvi_variance_threshold
: Filters static vegetation tracesClustering Parameters:
eps
: Controls cluster density - smaller values create tighter, more clustersmin_pts
: Minimum points needed to form a cluster - higher values reduce noise but may merge small clusterstemporal_weight
: Weight for NDVI time series features (higher = more NDVI similarity focus)spatial_weight
: Weight for spatial coordinates (higher = more spatial compactness)NetCDF file (created using processing/create_mdim_raster.py
) with:
ndvi
variable: NDVI values (dimensions: time, y, x or time, municipality, y, x)time
, y
, x
dimensionsmunicipality
dimension