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
- Laura Condon (lecondon@email.arizona.edu)
- Reed Maxwell (reedmaxwell@princeton.edu)
- Georgios Artavanis (ga6@princeton.edu)
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
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
Downwinding_Workflow_Example1.ipynb: Rectangular domain with no river networkDownwinding_Workflow_Example2.ipynb: Irregular domain with no river networkDownwinding_Workflow_Example3.ipynb: Rectangular domain with river networkDownwinding_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):
- create the mask in QGIS
- Using GRASS, clump it: r.clump
- change no data value to 0: r.null
- identify the ID of the big contiguous block (clump) you want to keep
- 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab7152199f383a9c16fe1ac7b28b3aeae211224891df7c7e43113096262f75af
|
|
| MD5 |
e554c522ba55e5bc11c64769fab04a26
|
|
| BLAKE2b-256 |
2b170712dcbe9f401d642024ffcbe47b02c2295c82bd7f59f37d57c10a9e6792
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
307e9e8e6bb855ae8298ec69117c619ca69f56cd3765cf4e41ce81a3661ef010
|
|
| MD5 |
134e50254e86e2f9dc3e1c065268a9be
|
|
| BLAKE2b-256 |
29d68e2710b4ab02bb2e2b383549a118742eea98da62e50dbf9bfe7ed2283f03
|