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
basin delineation
pfafstetter subbasins delineation
upstream accumulation
up- and downstream tracing and arithmetics
strahler stream order
hydrologically adjusting elevation
height above nearest drainage
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 stream_order method which returns a map with the Strahler order of each cell.
Browse the docs API for all methods
stream_order = flw.stream_order()
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.