River Geometry · DSM Analysis · EPSG:2154

Riverbank
Morphometrics

Python pipeline to automatically extract thalweg, bank toe, and bank edge from a Digital Surface Model (DSM) using centerline-based cross-sections and derivative (dZ/dX) detection — producing continuous morphological lines for hydraulic model input.

Python · rasterio · geopandas EPSG:2154 · 50 m spacing dZ/dX derivative detection Thalweg · Toe · Edge DSM · Cross-sections · HEC-RAS input

Overview

What this repo does

Defining a river's geometry for hydraulic modelling — the thalweg (deepest point), bank toes (where the bank meets the floodplain), and bank edges — traditionally requires manual digitising in GIS, which is slow and subjective. This pipeline automates the detection of these morphological features from a DSM using a cross-section approach: perpendicular transects are generated along the river centreline, elevation profiles are sampled and smoothed, and the first-derivative (dZ/dX) is analysed to locate break-of-slope points automatically.

The outputs are continuous geometric lines — thalweg, left/right bank toe, left/right bank edge — ready for export into HEC-RAS geometry or further spatial analysis in QGIS. Cross-sections are spaced at 50 m with a transect length of 200 m, in EPSG:2154.


Architecture

Four-module pipeline

Module 1
Generate Cross-Sections
Read river centreline (GeoPackage/Shapefile), generate perpendicular transects at 50 m spacing, 200 m length. Export as vector layer.
Module 2
Sample Elevation Profiles
Sample DSM elevation values along each cross-section using rasterio. Output: per-transect elevation profile arrays with distance from centreline.
Module 3
Detect Morphological Features
Smooth each profile, compute dZ/dX derivative, detect thalweg (minimum elevation), left/right bank toe and edge (break-of-slope from derivative peaks).
Module 4
Build Continuous Lines
Connect detected points across all cross-sections into continuous morphological lines (thalweg, toe, edge). Export as GeoPackage for QGIS / HEC-RAS.
00
Setup checktools/00_check_setup.py — verify environment, dependencies, input files present.
01
Centreline checktools/01_centerline_check.py — validate centreline geometry, CRS, direction.
02
Generate cross-sectionstools/02_generate_cross_sections.py — perpendicular transects at 50 m spacing, 200 m length.
03
DSM checktools/03_check_dsm.py — verify DSM extent covers all cross-sections, inspect NoData and resolution.
05
Sample all profilestools/05_sample_all_profiles.py — sample DSM elevation along every transect, save profile arrays.
12
Detect featurestools/12_detect_features_all.py — smooth + dZ/dX + detect thalweg / left-right toe / left-right edge for all cross-sections.
14
Build morpho linestools/14_build_morpho_lines.py — connect detected points into continuous line geometries.
15
Planview QA plottools/15_planview_qa_plot.py — generate plan-view map of all detected lines for visual inspection.

Key QA Figures

Output visualisations

Four QA figures are generated at key stages of the pipeline to validate geometry, profile sampling, feature detection, and final line outputs.

Cross-sections QA — spacing 50m, length 200m, EPSG:2154
Figure 1 — Module 1: Cross-sections QA. Perpendicular transects generated along the river centreline at 50 m spacing, 200 m length, in EPSG:2154. The blue line shows the centreline; transects are evenly spaced and correctly oriented perpendicular to flow direction.
Elevation profile and dZ/dX derivative for cross-section 0050
Figure 2 — Module 3: Profile & Derivative (XS 0050). Top panel: smoothed DSM elevation profile across the transect. Bottom panel: dZ/dX first derivative — peaks and troughs mark break-of-slope locations used to detect toe and edge positions.
Thalweg, bank toe and edge detection for cross-section 0050
Figure 3 — Module 3: Toe & Edge Detection (XS 0050). Detected morphological features plotted on the elevation profile: thalweg (minimum), left/right bank toes (inner break-of-slope), and left/right bank edges (outer break-of-slope).
Planview QA map of all continuous morphological lines
Figure 4 — Module 4: Planview QA. Final output — continuous morphological lines (thalweg, left/right bank toe, left/right bank edge) plotted in plan view over the river corridor. These lines are exported as GeoPackage for direct use in QGIS or HEC-RAS geometry.

Technical Details

Stack & repository structure

Python 3 rasterio geopandas numpy matplotlib Cross-section analysis dZ/dX derivative Thalweg extraction Bank toe & edge DSM · EPSG:2154 HEC-RAS geometry input GeoPackage output
riverbank-morphometrics/
├── riverbank_morpho/       ← Python package
│   ├── config.py          ← paths, parameters (spacing, length, threshold)
│   ├── cross_sections.py  ← Module 1: transect generation
│   ├── io_raster.py       ← DSM sampling utilities
│   ├── io_vector.py       ← GeoPackage read/write
│   ├── detection.py       ← Module 3: dZ/dX, thalweg, toe, edge
│   └── plotting.py        ← QA figure generation
├── tools/                ← entry-point scripts (run in order)
│   ├── 00_check_setup.py
│   ├── 01_centerline_check.py
│   ├── 02_generate_cross_sections.py
│   ├── 03_check_dsm.py
│   ├── 05_sample_all_profiles.py
│   ├── 12_detect_features_all.py
│   ├── 14_build_morpho_lines.py
│   └── 15_planview_qa_plot.py
├── inputs/               ← centreline shapefile + GeoPackage
├── docs/images/          ← QA figures (tracked in repo)
├── settings.ini          ← user-configurable parameters
├── requirements.txt
└── README.md