A Python package for delineating watersheds from a DEM and pour point.
Project description
Watershed Delineation
A Python package for automatic watershed delineation from a Digital Elevation Model (DEM) and a pour point (longitude & latitude).
It uses WhiteboxTools, GeoPandas, and Rasterio to perform hydrologic analysis and export shapefiles with watershed attributes.
📦 Installation
pip install watershed-delineation
Requirements: Python 3.9 or later. Dependencies like rasterio and geopandas ship wheels for most platforms, but a recent pip is recommended.
🚀 Usage
From Python
from watershed_delineation.core import delineate_watershed
# Input parameters
dem_path = r"F:\data\dem.tif"
pour_lon = 32.561170
pour_lat = 39.835840
output_dir = r"C:\results"
watershed_name = "my_basin"
# Run delineation
result_path = delineate_watershed(
dem_path=dem_path,
pour_lon=pour_lon,
pour_lat=pour_lat,
output_dir=output_dir,
name=watershed_name,
export_lfp=True # also export Longest Flow Path
)
print("Watershed shapefile saved at:", result_path)
From the Command Line
After installation, run:
delineate_watershed "F:\data\dem.tif" 32.561170 39.835840 -o "C:\results" -n "my_basin" --export-lfp
Arguments:
dem_file→ Path to DEM raster (.tif)pour_lon→ Longitude of pour pointpour_lat→ Latitude of pour point-o,--output→ Output directory (default: current dir)-n,--name→ Base name of shapefile (default: watershed_lat_lon)--export-lfp→ Export Longest Flow Path shapefile
📂 Output
-
my_basin.shp→ Watershed polygon shapefile with attributes:- Area, perimeter
- Longest flow path length
- Form factor, circularity ratio
- Elevation statistics (min, max, mean)
- Mean slope
- Drainage density
- Pour point coordinates
-
my_basin_lfp.shp(optional) → Longest flow path polyline shapefile
🛠 Development
Clone and install in editable mode:
git clone https://github.com/fyec/watershed-delineation.git
cd watershed-delineation
pip install -e .
Rebuild after code changes with:
python -m build
📌 Project Links
👤 Author
Developed by FYEC
Date: August 2025
License: MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file watershed_delineation-0.1.0.tar.gz.
File metadata
- Download URL: watershed_delineation-0.1.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
565dc2000d44732a3556b571fdcd5971ecf003a7818fd19e402caaef2d9dae4f
|
|
| MD5 |
2a47362c6e0f4fd053f6d45d305db32e
|
|
| BLAKE2b-256 |
7760b7563e03baa61b3c6a8f79ae264706b903f09e689bcf92a907bd2c812fde
|
File details
Details for the file watershed_delineation-0.1.0-py3-none-any.whl.
File metadata
- Download URL: watershed_delineation-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
178b355c0096379fb90fbbfb70add8dec6642650056b3e8e90910a27e2eda711
|
|
| MD5 |
38e672e2b413b6a0bc961be728eb4aa1
|
|
| BLAKE2b-256 |
4c182e7bff7da29e90321998396434ed96ed5117bed69bf088479c409317b28d
|