Skip to main content

Python toolkit for topographic processing for hydrologic models - a port of the R PriorityFlow package

Project description

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.

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

priority_flow-1.0.1.tar.gz (437.9 kB view details)

Uploaded Source

Built Distribution

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

priority_flow-1.0.1-py3-none-any.whl (453.3 kB view details)

Uploaded Python 3

File details

Details for the file priority_flow-1.0.1.tar.gz.

File metadata

  • Download URL: priority_flow-1.0.1.tar.gz
  • Upload date:
  • Size: 437.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.9.7 Linux/4.18.0-553.117.1.el8_10.x86_64

File hashes

Hashes for priority_flow-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ab7152199f383a9c16fe1ac7b28b3aeae211224891df7c7e43113096262f75af
MD5 e554c522ba55e5bc11c64769fab04a26
BLAKE2b-256 2b170712dcbe9f401d642024ffcbe47b02c2295c82bd7f59f37d57c10a9e6792

See more details on using hashes here.

File details

Details for the file priority_flow-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: priority_flow-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 453.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.9.7 Linux/4.18.0-553.117.1.el8_10.x86_64

File hashes

Hashes for priority_flow-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 307e9e8e6bb855ae8298ec69117c619ca69f56cd3765cf4e41ce81a3661ef010
MD5 134e50254e86e2f9dc3e1c065268a9be
BLAKE2b-256 29d68e2710b4ab02bb2e2b383549a118742eea98da62e50dbf9bfe7ed2283f03

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