An open source solution that can serve as an alternative way of ArcPy
Watershed delineation is the process of identifying the boundary of a land area where all precipitation and surface water drain to a single, common outlet, such as a point on a river, a lake, or a reservoir. Think of it as drawing a line around a funnel; everything that falls inside the line will eventually pass through the spout at the bottom. The spout is the "pour point" or outlet.
There are many commercial and open source tools available for watershed delineation.
PySheds is a popular open source library for watershed delineation. However, it has some limitations for a regional scale watershed delineation.
- It requires a pre-defined pour point. Although technically only if system converged into one outlet can be called a watershed, in practice, it is often useful to delineate potential multiple watersheds in a region.
ArcPy is a powerful tool for watershed delineation, but it is a commercial product and requires a license.
- Not only is it licensed, but it is also a Windows-only solution, which limits its accessibility for many users.
This project aims to provide an open source, cross-platform solution for watershed delineation that can handle multiple pour points and is easy to use.
WhiteboxToolsis used for the core hydrological operations.GDAL/OGRconvert the final raster watershed to polygonsGeoPandasdissolves the polygons.- Uses
rasterstatsto add the zonal statistics
This project utilizes the whitebox-python package for geospatial analysis.
conda create -n watershed python=3.10
conda activate watershed
conda install gdal
pip install -r requirements.txtFor run the code, you can either run the pipelineStarter.py directly or run the catchmentDelineation.py script with the following command:
python catchmentDelineation.py --dem your_dem.tif --pour_points your_pour_points.shp --output_dir your_output_directory- Rebuild the core hydrological operations using Python.
- Now I define stream by the flow accumulation threshold, which is not ideal. I should apply a more sophisticated method to define the stream network.