Modified Medial Axis Transform for River Centerline Extraction and Water-surface Width Estimation (MMATCWE)
Accurate river centerline extraction and water-surface width estimation are crucial for hydrological modeling, river morphology studies, and environmental monitoring. Traditional methods can be time-consuming and require manual intervention, especially when dealing with large datasets or complex river geometries.
To address these challenges, we developed the Modified Medial Axis Transform for River Centerline Extraction and Water-surface Width Estimation (MMATCWE). This Python-based package automates the process of extracting river centerlines and estimating water-surface widths from raster images, leveraging a modified medial axis transform approach. It provides robust and efficient tools for processing various types of river imagery.
The architecture of mmatcwe integrates key modules for image processing, medial axis transformation, and width estimation. All module codes are in the source (src) folder.
mmatcwe/
├── docs/
│ └── sampledata/
│ └── mmatcwe_usage.ipynb
├── Images/
│ └── flowchart.jpg
│ └── directorystructure.png
├── src/
│ └── mmatcwe/
│ ├── centerline_extraction.py
│ ├── width_estimation.py
│ ├── utils.py
│ └── __init__.py
├── tests/
│ └── test_mmatcwe.py
├── setup.py
├── README.md
└── LICENSEThe graphical representation of the mmatcwe pipeline can be summarized as follows in Figure 1. It shows the interconnected steps within mmatcwe for automated river centerline extraction and width estimation.
This framework is published as a Python package on PyPI (https://pypi.org/project/mmatcwe/). Install the package using pip and import it into your workflows:
# Install the framework
pip install mmatcwe
# Use the framework in your workflows using poetry
poetry add mmatcweImport the package into your Jupyter Notebook or Python IDE:
# Import the package
import mmatcwe as mcNote: Detailed usage instructions and examples are provided in docs/mmatcwe_usage.ipynb.
The main directory should contain the raster images for processing. If you have multiple river segments or study areas, organize them into subfolders within the main directory.
main_dir = Path('./path/to/main/dir')The mmatcwe framework provides modules for centerline extraction and width estimation.
Table 1: Modules in mmatcwe.
| Module Name | Objective | Arguments | Outputs |
|---|---|---|---|
extract_centerline |
Extracts the river centerline from a raster image. | raster_path: Path to the raster image, spatial_resolution: Spatial resolution of the raster. |
GeoDataFrame containing the centerline geometry. |
estimate_width |
Estimates the water-surface width along the extracted centerline. | raster_path: Path to the raster image, centerline_gdf: GeoDataFrame containing the centerline. |
DataFrame containing width estimates along the centerline. |
Figure 2: Example output from MMATCWE.
| ! | [Add any acknowledgements here] |
Contact [Pawan Thapa/Contact Information] for more details.


