Fast methods to work with hydro- and topography data in pure Python.
Project description
PyFlwDir
Fast methods to work with hydro- and topography data in pure Python.
Methods include:
flow direction upscaling
(sub)basin delineation
pfafstetter subbasins delineation
upstream accumulation
up- and downstream tracing and arithmetics
strahler stream order
hydrologically adjusting elevation
height above nearest drainage
vectorizing stream features
many more!
Example
Here we show an example of a 30 arcsec D8 map of the Rhine basin which is saved in as 8-bit GeoTiff. We read the flow direction, including meta-data using rasterio to begin with.
import rasterio
with rasterio.open('data/rhine_d8.tif', 'r') as src:
flwdir = src.read(1)
transform = src.transform
latlon = src.crs.to_epsg() == 4326
Next, we parse this data to a FlwdirRaster object, the core object to work with flow direction data. The most common way to initialize a FlwdirRaster object is based on gridded flow direction data in D8, LDD or NEXTXY format using the pyflwdir.from_array method. Optional arguments describe the geospatial location of the gridded data. In this step the D8 data is parsed to an actionable format.
import pyflwdir
flw = pyflwdir.from_array(flwdir, ftype='d8', transform=transform, latlon=latlon)
# When printing the FlwdirRaster instance we see its attributes.
print(flw)
Now all pyflwdir FlwdirRaster methods are available, for instance the subbasins method which creates a map with unique IDs for subbasin with a minumum stream_order.
Browse the docs API for all methods
subbasins = flw.subbasins()
Getting started
Install the package from pip using
$ pip install pyflwdir
Development and Testing
See CONTRIBUTING.rst
Documentation
See docs
License
See LICENSE
Changes
See CHANGESLOG.rst
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
File details
Details for the file pyflwdir-0.4.3.tar.gz.
File metadata
- Download URL: pyflwdir-0.4.3.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e43832afaaed7aecd09218947fc7b52719c38681c23beb7f4700f06090a9de1f
|
|
| MD5 |
ca2ca4c256db2267ad8e2d55611aaadd
|
|
| BLAKE2b-256 |
a8d4a2cf506751aeb6d15995fd3a9576adae52aa3e43429b7fdcca411fbb4837
|