A comprehensive waterway monitoring and trip planning system for Berlin, combining an iOS mobile application with satellite-based water quality analysis and riparian vegetation monitoring.
Smart Waterways is a multi-faceted project that enables users to plan waterway trips while providing scientific insights into water quality and ecosystem health through remote sensing data analysis. The project integrates:
- iOS Mobile App: Interactive trip planning for Berlin's waterways
- Water Quality Monitoring: Satellite-based analysis of water quality metrics
- Vegetation Analysis: Riparian zone vegetation health monitoring
An iOS application for planning and managing waterway trips in Berlin's rivers, lakes, and canals.
- 🗺️ Interactive Map Interface: Tap on waterways to set start and end points for your trip
- 🚤 Multiple Vessel Types: Support for Motor Boats, Kayaks, and Stand-Up Paddleboards
- 💧 Waterbody Validation: Ensures selected points are on water (rivers, lakes, canals) before creating trips
- 🛣️ Smart Route Planning: Automatically generates waterway routes using MapKit and synthetic route generation
- 📍 Trip Management: Create, view, and delete trips with start/end points and timestamps
- 🎨 Modern UI: Built with SwiftUI featuring smooth animations and intuitive interactions
App Demo Video:
Dashboard View:
- iOS 17.0 or later
- Xcode 15.0 or later
- Swift 5.0 or later
-
Install XcodeGen:
brew install xcodegen
-
Generate the Xcode project:
cd app xcodegen generate open build-zone.xcodeproj -
Build and run in Xcode (⌘R)
Satellite-based water quality monitoring using Sentinel-2 imagery and the MAGO (MAnaging water quality using GOvernment data) algorithm. This notebook implements a comprehensive water quality monitoring system that analyzes multiple water quality parameters from satellite imagery and validates them against ground truth measurements.
The notebook uses Sentinel-2 L2A satellite imagery to calculate 8 different water quality indices using spectral band ratios and established algorithms. It performs temporal analysis across multiple years and lakes, and validates predictions using official Berlin water quality monitoring data.
The notebook calculates 8 indices simultaneously:
- Chl-a (Mishra 2012): Chlorophyll-a concentration using NDCI-based algorithm (mg/m³)
- Chl-a > 5 mg/m³ (Soria-Perpinyà 2021): High chlorophyll-a concentration algorithm
- Chl-a < 5 mg/m³ (Soria-Perpinyà 2021): Low chlorophyll-a concentration algorithm
- Cyanobacteria (Potes et al. 2018): Phycocyanin-based cyanobacteria detection (cells/mL)
- Phycocyanin (Soria-Perpinyà 2021): Phycocyanin concentration (mg/m³)
- Turbidity (Zhan et al. 2022): Water turbidity in NTU
- CDOM (Soria-Perpinyà 2021): Colored Dissolved Organic Matter (µg/L)
- TSS (Soria-Perpinyà 2021): Total Suspended Solids (mg/L)
-
Configuration Setup:
- Configure Sentinel Hub credentials for Copernicus Data Space Ecosystem
- Define area of interest (AOI) bounding boxes for Berlin lakes
- Set resolution (10m default) and time intervals
-
Multi-Year Analysis (2017-2025):
- Requests Sentinel-2 imagery for summer months (May-September) for each year
- Calculates all 8 water quality indices using custom evalscript
- Applies cloud masking and water body filtering (NDWI threshold)
- Generates time-series plots showing trends across years
- Normalizes metrics for comparison
-
Single Summer Analysis (2025):
- Divides summer into 10-day intervals
- Analyzes temporal variation within a single season
- Compares metrics across different time periods
- Overlays temperature data from Meteostat API
-
Multi-Lake Comparison:
- Analyzes multiple Berlin lakes simultaneously:
- Müggelsee (primary focus)
- Krumme Lanke / Schlachtensee
- Other Berlin water bodies
- Compares normalized metrics across lakes
- Identifies lake-specific patterns
- Analyzes multiple Berlin lakes simultaneously:
-
Validation with Ground Truth:
- Downloads official water quality data from Berlin LAGESO
- Parses measurements including:
- E. coli (KBE/100ml)
- Intestinal Enterococci (KBE/100ml)
- Coliform bacteria (KBE/100ml)
- Water clarity/Secchi depth (m)
- Cyanobacteria chlorophyll-a (µg/L)
- Aligns satellite-derived metrics with measurement dates
- Uses Ridge regression to predict measured parameters from satellite metrics
-
Predictive Modeling:
- Trains Ridge regression models on satellite metrics
- Predicts water clarity, E. coli, and cyanobacteria levels
- Validates predictions against actual measurements
- Tests model generalization across different lakes
- Cloud Filtering: Uses Scene Classification Layer (SCL) to filter clouds and shadows
- Water Masking: NDWI threshold to ensure only water pixels are analyzed
- Spatial Aggregation: Mean/median aggregation across water pixels
- Temporal Interpolation: Resamples to daily resolution for alignment with measurements
- Normalization: Normalizes metrics for cross-year and cross-lake comparison
# Area of Interest (Müggelsee example)
aoi_coords_wgs84 = [13.614979, 52.423674, 13.688364, 52.450779]
# Resolution in meters
resolution = 10 # Can be adjusted (lower = higher detail, larger files)
# Time intervals
summer_intervals = [("2017-05-01", "2017-09-01"), ...] # Yearly
current_summer_intervals = [("2025-05-01", "2025-05-11"), ...] # 10-day periods- Time-series plots: Year-over-year trends for all metrics
- Comparison plots: Multi-lake comparisons with temperature overlay
- Validation plots: Predicted vs. measured water quality parameters
- Animation: MP4 video showing water quality changes over years (
muggelsee_water_quality_by_year.mp4) - Prediction visualizations: PNG files showing model predictions (
predicted_measurements_2025_summer.png)
- Sentinel-2 L2A: Satellite imagery via Copernicus Data Space Ecosystem
- Berlin LAGESO: Official water quality measurements from LAGESO
- Meteostat API: Historical temperature data for Berlin
sentinelhub>=3.11.3 # Sentinel Hub Python package
pandas>=2.0 # Data manipulation
numpy>=2.0 # Numerical operations
matplotlib # Plotting
scikit-learn # Ridge regression for predictions
meteostat # Weather data API
seaborn # Enhanced visualization
scipy # Scientific computing-
Install Dependencies:
pip install sentinelhub pandas numpy matplotlib scikit-learn meteostat seaborn scipy
-
Obtain Sentinel Hub Credentials:
- Register at Copernicus Data Space Ecosystem
- Create an OAuth Client in User Settings
- Copy
client_idandclient_secret
-
Configure Credentials:
- Run the credential configuration cell in the notebook
- Credentials are saved to a profile named "cdse" for reuse
-
Run Analysis:
- Execute cells sequentially
- Adjust AOI coordinates and time intervals as needed
- Results are displayed inline and saved as images/videos
# Define area of interest
aoi_coords_wgs84 = [13.614979, 52.423674, 13.688364, 52.450779]
# Generate summer intervals for a year
summer_intervals = [gen_year_summer(2024)] # May 1 - Sep 1
# Request data
request = SentinelHubRequest(
evalscript=evalscript_all_metrics,
input_data=[...],
bbox=aoi_bbox,
size=aoi_size,
config=config
)
# Get results
response = request.get_data()
water_quality_data = response[0]["indices.tif"] # Shape: [H, W, 8]- Mishra, S., et al. (2012). NDCI-based chlorophyll-a estimation
- Soria-Perpinyà, X., et al. (2021). Multiple water quality algorithms
- Potes, M., et al. (2018). Cyanobacteria detection
- Zhan, Y., et al. (2022). Turbidity estimation
Analysis of shoreline vegetation health using NDVI (Normalized Difference Vegetation Index) from Sentinel-2 satellite imagery. This notebook focuses on monitoring the health and extent of riparian (shoreline) vegetation around Berlin's water bodies, which is crucial for ecosystem health and water quality.
The notebook analyzes vegetation in a 50-meter buffer zone inland from water bodies, providing insights into riparian ecosystem health over time. Healthy riparian vegetation helps filter pollutants, prevent erosion, and support biodiversity.
- Riparian Zone: The transition area between water and land, critical for ecosystem health
- NDVI (Normalized Difference Vegetation Index): Spectral index measuring vegetation health
- Formula:
NDVI = (NIR - Red) / (NIR + Red) - Values range from -1 to 1, where >0.3 typically indicates healthy vegetation
- Formula:
- Shoreline Buffer: 50-meter zone measured inland from the water edge
-
Area Definition:
- Define bounding box for area of interest (Müggelsee region by default)
- Set resolution (10m) and shoreline buffer width (50m)
-
Water Body Identification:
- Request Sentinel-2 Scene Classification Layer (SCL) for summer months (May-August)
- Extract water pixels (SCL class 6: "Water")
- Create binary water mask
-
Shoreline Delineation:
- Use distance transform to identify pixels within 50m of water
- Create riparian zone mask (land pixels within buffer distance)
- Apply morphological operations to smooth shoreline
-
NDVI Calculation:
- Request Sentinel-2 Red (B04) and Near-Infrared (B08) bands
- Calculate NDVI for each pixel:
(B08 - B04) / (B08 + B04) - Mask to only riparian zone pixels
- Filter out invalid values (NaN, clouds, shadows)
-
Statistical Analysis:
- Calculate mean NDVI for each year
- Compute standard deviation
- Calculate 95% confidence intervals
- Generate time-series visualizations
-
Temporal Analysis:
- Process data for years 2017-2025
- Aggregate across summer months (May-August) for each year
- Track year-over-year changes in vegetation health
Shoreline Buffer Creation:
def shoreline_band_inland(water_mask, pixel_size_m, shore_width_m):
"""
Creates a mask of land pixels within shore_width_m of water,
measured inland from the water edge.
"""
land = ~water_mask
dist_to_water_m = distance_transform_edt(land, sampling=pixel_size_m)
shore = land & (dist_to_water_m > 0) & (dist_to_water_m <= shore_width_m)
return shoreNDVI Calculation:
- Uses Sentinel-2 bands B04 (Red) and B08 (NIR)
- Applies water mask and riparian zone mask
- Filters out clouds, shadows, and invalid pixels
- Aggregates statistics from valid pixels only
# Area of Interest (Müggelsee region)
AOI_COORDS_WGS84 = [13.552322, 52.399591, 13.799515, 52.485394]
# Resolution in meters
RESOLUTION = 10
# Shoreline buffer width in meters
SHORE_WIDTH = 50 # 50m inland from water edge
# Time period for analysis (summer months)
time_intervals = [
("2017-05-01T00:00:00Z", "2017-08-31T23:59:59Z"),
# ... for each year 2017-2025
]-
Annual NDVI Maps:
- PNG images showing NDVI distribution for each year (
ndvi_2017.png, etc.) - Color-coded visualization of vegetation health
- Masked to show only riparian zones
- PNG images showing NDVI distribution for each year (
-
Time-Series Plots:
- Mean NDVI over time with confidence intervals
- Standard deviation trends
- Year-over-year comparison
-
CSV Export (
ndvi.csv):years,mean,std,ci 2017,0.523,0.142,0.008 2018,0.531,0.145,0.009 ...
-
Statistical Summary:
- Mean NDVI per year
- Standard deviation
- 95% confidence intervals
- Sample sizes (number of valid pixels)
- Cloud Filtering: Uses SCL to exclude clouds, shadows, and invalid pixels
- Precise Shoreline Detection: Distance transform ensures accurate buffer zone
- Temporal Consistency: Uses same time period (summer months) for all years
- Statistical Rigor: Provides confidence intervals for trend analysis
- Visualization: Generates publication-ready plots and maps
-
NDVI Values:
- < 0: Water, clouds, or no vegetation
- 0.0 - 0.3: Sparse or stressed vegetation
- 0.3 - 0.6: Moderate vegetation health
- > 0.6: Dense, healthy vegetation
-
Trends:
- Increasing NDVI: Improving vegetation health (reforestation, restoration)
- Decreasing NDVI: Declining health (drought, pollution, development)
- Stable NDVI: Consistent ecosystem conditions
- Sentinel-2 L2A: Satellite imagery via Copernicus Data Space Ecosystem
- Scene Classification Layer (SCL): Pixel-level classification for water/land/cloud detection
sentinelhub>=3.11.3 # Sentinel Hub Python package
pandas>=2.0 # Data manipulation
numpy>=2.0 # Numerical operations
matplotlib # Plotting
scipy # Distance transforms, image processing
seaborn # Enhanced visualization-
Install Dependencies:
pip install sentinelhub pandas numpy matplotlib scipy seaborn
-
Configure Sentinel Hub:
- Same credentials setup as water quality notebook
- Uses "cdse" profile if already configured
-
Run Analysis:
- Execute cells sequentially
- Adjust AOI coordinates and buffer width as needed
- Results are saved as images and CSV
# Define parameters
AOI_COORDS_WGS84 = [13.552322, 52.399591, 13.799515, 52.485394]
RESOLUTION = 10
SHORE_WIDTH = 50
# Request SCL for water detection
scl_request = SentinelHubRequest(
evalscript=evalscript_scl,
input_data=[...],
bbox=aoi_bbox,
size=aoi_size,
config=config
)
# Create riparian mask
water_mask = (scl_data == 6) # SCL class 6 = water
shore_mask = shoreline_band_inland(water_mask, RESOLUTION, SHORE_WIDTH)
# Calculate NDVI for riparian zone
ndvi_data = ndvi_request.get_data()[0]
ndvi_riparian = np.where(shore_mask, ndvi_data, np.nan)
# Calculate statistics
mean_ndvi = np.nanmean(ndvi_riparian)
std_ndvi = np.nanstd(ndvi_riparian)- Ecosystem Monitoring: Track riparian health over time
- Restoration Assessment: Evaluate effectiveness of restoration projects
- Water Quality Correlation: Compare with water quality metrics
- Climate Impact: Assess effects of climate change on vegetation
- Urban Planning: Inform development decisions near water bodies
Smart-Waterways/
├── app/ # iOS Application
│ ├── build-zone/
│ │ ├── Models/
│ │ │ └── Trip.swift # Trip data model
│ │ ├── Services/
│ │ │ ├── WaterbodyValidator.swift # Water validation service
│ │ │ └── WaterRoutePlanner.swift # Route planning service
│ │ ├── ViewModels/
│ │ │ └── TripViewModel.swift # Trip management logic
│ │ ├── Views/
│ │ │ ├── HomeView.swift # Main map interface
│ │ │ └── Components/ # UI components
│ │ └── WaterFlowBerlinApp.swift # App entry point
│ └── project.yml # XcodeGen configuration
│
├── mago_water_quality.ipynb # Water quality analysis notebook
├── vegetation_reparian_zone.ipynb # Vegetation analysis notebook
│
├── muggelsee_water_quality_by_year.mp4 # Water quality animation
├── predicted_measurements_2025_summer.png # Prediction visualization
└── README.md # This file
The app follows a clean architecture pattern:
- Models: Data structures (
Trip,VesselType) - Services: Core business logic (
WaterbodyValidator,WaterRoutePlanner) - ViewModels: Presentation logic (
TripViewModel) - Views: SwiftUI user interface components
-
WaterbodyValidator: Uses MapKit POI search and reverse geocoding to validate coordinates are on water bodies. Includes caching and rate limiting for API calls.
-
WaterRoutePlanner: Plans routes along waterways by:
- Attempting to use MapKit directions
- Falling back to synthetic route generation with natural curves
- Validating route points are on water
- Deduplicating and optimizing route coordinates
-
TripViewModel: Manages trip state, handles user interactions, and coordinates between services and views.
-
Create a Trip:
- Tap the "+" button to start creating a new trip
- Select your vessel type (Motor Boat, Kayak, or Stand-Up Paddle)
- Tap on the map to set your start point (must be on water)
- Tap again to set your end point
- Tap "Create Trip" to generate the route
-
View Trips:
- Tap the list icon to view all your trips
- Select a trip to view its route on the map
-
Delete Trips:
- Swipe left on a trip in the list to delete it
-
Initial Setup:
# Install required packages pip install sentinelhub pandas numpy matplotlib scikit-learn meteostat seaborn scipy -
Configure Credentials:
- Register at Copernicus Data Space Ecosystem
- Create OAuth Client and obtain
client_idandclient_secret - Run the credential configuration cell in the notebook
- Credentials are saved to "cdse" profile for future use
-
Configure Analysis Parameters:
- Set area of interest (AOI) coordinates for your target lake
- Adjust resolution (default: 10m)
- Define time intervals (yearly or seasonal)
-
Run Analysis:
- Execute cells sequentially
- For multi-year analysis: Run cells that process 2017-2025 data
- For single summer: Run cells that analyze 10-day intervals
- For validation: Run cells that download and compare with LAGESO data
-
View Results:
- Time-series plots show trends over years
- Comparison plots show multi-lake differences
- Validation plots compare predictions with measurements
- Animation video shows temporal changes
-
Export Results:
- Plots are automatically saved as PNG files
- Animation saved as MP4
- Data can be exported to CSV for further analysis
-
Initial Setup:
# Install required packages pip install sentinelhub pandas numpy matplotlib scipy seaborn -
Configure Credentials:
- Use same Sentinel Hub credentials as water quality notebook
- If "cdse" profile exists, it will be reused automatically
-
Configure Analysis Parameters:
- Set AOI coordinates (default: Müggelsee region)
- Adjust resolution (default: 10m)
- Set shoreline buffer width (default: 50m)
- Define time periods for analysis (default: summer months)
-
Run Analysis:
- Execute cells sequentially
- The notebook processes each year from 2017-2025
- For each year:
- Requests SCL data for water detection
- Creates riparian zone mask
- Calculates NDVI
- Generates visualization
-
View Results:
- Annual NDVI maps show spatial distribution
- Time-series plot shows trends with confidence intervals
- Statistical summary provides mean, std, and CI values
-
Export Results:
- NDVI maps saved as PNG files (
ndvi_YYYY.png) - Statistics exported to CSV (
ndvi.csv) - Plots can be saved for publications
- NDVI maps saved as PNG files (
- SwiftUI: Modern declarative UI framework
- MapKit: Map display and location services
- CoreLocation: Location and geocoding services
- XcodeGen: Project generation from YAML configuration
- Sentinel Hub Python: Access to Copernicus satellite data
- Sentinel-2 L2A: Satellite imagery for water quality and vegetation analysis
- Python Scientific Stack: pandas, numpy, matplotlib, scikit-learn
- Jupyter Notebooks: Interactive data analysis environment
- Copernicus Data Space Ecosystem: Sentinel-2 satellite imagery
- Berlin LAGESO: Official water quality measurements
- Meteostat: Historical weather data
- MapKit: Map data and geocoding services
The project uses XcodeGen for project configuration. To modify project settings, edit app/project.yml and regenerate the project.
Both notebooks require Sentinel Hub credentials. See the notebooks for detailed setup instructions.
This project demonstrates:
- Remote Sensing for Water Quality: Using satellite imagery to monitor water quality parameters
- Machine Learning for Prediction: Predicting water quality metrics from satellite data
- Ecosystem Monitoring: Tracking riparian vegetation health over time
- Mobile Integration: Combining scientific data with practical trip planning tools
- Integration of water quality data into the iOS app
- Real-time water quality alerts
- Historical water quality visualization in trip planning
- Expanded analysis to more Berlin water bodies
- User-contributed water quality observations
- Copernicus Data Space Ecosystem for satellite imagery
- Berlin LAGESO for water quality monitoring data
- Sentinel Hub for data access infrastructure

