Skip to main content

priority_flow

priority_flow is a toolkit for topographic processing for hydrologic models. This repo contains an python package and a set of workflow examples (see instructions below). This is the Python version of the R PriorityFlow package.

Development Team

Citation

For more details on the model and if you use priority_flow in published work please cite the following reference:
Condon, LE and RM Maxwell (2019). Modified priority flood and global slope enforcement algorithm for topographic processing in physically based hydrologic modeling applications. Computers & Geosciences, doi:10.1016/j.cageo.2019.01.20.

Installation

$ pip install priority_flow

Getting started

The best way to get started with this toolset would be to walk through the Workflow_Example_Notebook.ipynb Jupyter notebook in the 'Notebooks' section of this documentation. In addition, you can walk through the four Downwinding workflows. You can also refer to the documentation for each individual function provided in this package.

DEM Processing

The DEM processing code is a modified version of the 'Priority Flood' algorithm which is a depression filling algorithm (Wang and Liu 2006; Barnes et al., 2014; Zhou, 2016). This is an optimal approach that processes the DEM to ensure every cell drains to the border.

As implemented here there are options to ensure drainage to the edges of a regular rectangular domain or the user can provide a mask for an irregular domain. NOTE: if you are providing a mask for an irregular domain boundary you must ensure that your mask is D4 contiguous. See the mask tip below for one approach to achieve this using grass.

Additionally, a second processing option is provided if there is an river network that you would like to enforce. In this case, the river network is provided first as a mask to the processing algorithm to ensure that every identified river cell drains to the boundary of the domain (regular or irregular). This step will also ensure a D4 connected river network (i.e. stair stepping around any diagonal river neighbors). Next the remaining cells are processed using the river network as the boundary, ensuring that every other cell drains either to a river or to a boundary. For examples of this approach refer to Downwinding_Workflow_Example3.ipynb and Downwinding_Workflow_Example4.ipynb.

Slope Calculations

There are two slope calculations functions in this repo:

slope_calc_upwind calculates slopes in the x and y direction down-winded to be consistent with the ParFlow OverlandFLow boundary condition.

slope_calc_standard calculates slopes in the x and y direction using indexing to be consistent with the ParFlow OverlandKinematic and OverlandDiffusive boundary conditions. This is the approach that is used in the main workflow example.

Workflow Scripts

  1. Workflow_Example_Notebook.ipynb: This is the most updated workflow example and the one I recommend starting from.

The next four examples show the older slope calculation function with downwinding

  1. Downwinding_Workflow_Example1.ipynb: Rectangular domain with no river network
  2. Downwinding_Workflow_Example2.ipynb: Irregular domain with no river network
  3. Downwinding_Workflow_Example3.ipynb: Rectangular domain with river network
  4. Downwinding_Workflow_Example4.ipynb: Irregular domain with river network

Tips

If you want to process your DEM within a pre-defined watershed mask and you need help creating that mask. An example workflow using QGIS and GRASS to ensure a D4 connected mask (i.e. one where you don't have any cells that are only connected to the rest of the domain diagonally):

  1. create the mask in QGIS
  2. Using GRASS, clump it: r.clump
  3. change no data value to 0: r.null
  4. identify the ID of the big contiguous block (clump) you want to keep
  5. re-mask:("NullRaster@1"=65)*1+("NullRaster@1" != 65)*0

References

  • Barnes, R., C. Lehman, and D. Mulla, Priority-flood: An optimal depression-filling and watershed-labeling algorithm for digital elevation models. Computers & Geosciences, 2014. 62: p. 117-127.
  • Wang, L. and H. Liu, An efficient method for identifying and filling surface depressions in digital elevation models for hydrologic analysis and modelling. International Journal of Geographical Information Science, 2006. 20(2): p. 193-213.
  • Zhou, G., Z. Sun, and S. Fu, An efficient variant of the Priority-Flood algorithm for filling depressions in raster digital elevation models. Computers & Geosciences, 2016. 90: p. 87-96.

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

priority_flow was created by Laura E. Condon and Reed M. Maxwell. It is licensed under the terms of the GNU General Public License v3.0 license.

Credits

priority_flow was created with cookiecutter and the py-pkgs-cookiecutter template.

Metadata

Release files for priority_flow 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for priority_flow 1.0.1
File Size Uploaded
priority_flow-1.0.1.tar.gz 437.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for priority_flow 1.0.1
File Interpreter ABI Platform
priority_flow-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 891.2 kB

Release files / priority_flow-1.0.1.tar.gz

Download URL priority_flow-1.0.1.tar.gz
Size 437.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ab7152199f383a9c16fe1ac7b28b3aeae211224891df7c7e43113096262f75af
BLAKE2b-256 checksum
How to use checksums
2b170712dcbe9f401d642024ffcbe47b02c2295c82bd7f59f37d57c10a9e6792
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.9.7 Linux/4.18.0-553.117.1.el8_10.x86_64

Release files / priority_flow-1.0.1-py3-none-any.whl

Download URL priority_flow-1.0.1-py3-none-any.whl
Size 453.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
307e9e8e6bb855ae8298ec69117c619ca69f56cd3765cf4e41ce81a3661ef010
BLAKE2b-256 checksum
How to use checksums
29d68e2710b4ab02bb2e2b383549a118742eea98da62e50dbf9bfe7ed2283f03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.9.7 Linux/4.18.0-553.117.1.el8_10.x86_64

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page