Skip to main content

Fast methods to work with hydro- and topography data in pure Python.

Project description

https://gitlab.com/deltares/wflow/pyflwdir/badges/master/coverage.svg

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

Authors

See AUTHORS.txt

Changes

See CHANGESLOG.rst

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

pyflwdir-0.4.5.tar.gz (1.1 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page