Skip to main content

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 point
  • pour_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

watershed_delineation-0.1.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

watershed_delineation-0.1.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

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

Hashes for watershed_delineation-0.1.0.tar.gz
Algorithm Hash digest
SHA256 565dc2000d44732a3556b571fdcd5971ecf003a7818fd19e402caaef2d9dae4f
MD5 2a47362c6e0f4fd053f6d45d305db32e
BLAKE2b-256 7760b7563e03baa61b3c6a8f79ae264706b903f09e689bcf92a907bd2c812fde

See more details on using hashes here.

File details

Details for the file watershed_delineation-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for watershed_delineation-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 178b355c0096379fb90fbbfb70add8dec6642650056b3e8e90910a27e2eda711
MD5 38e672e2b413b6a0bc961be728eb4aa1
BLAKE2b-256 4c182e7bff7da29e90321998396434ed96ed5117bed69bf088479c409317b28d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page