Skip to main content

Flow direction upscaling toolkit (DMM, NSA, COTAT)

Project description

fdup

fdup is a Python toolkit containing algorithms for upscaling D8 flow direction grids.

Currently implemented algorithms

Installation

From PyPI:

pip install fdup

From the repository root:

git clone https://github.com/sasjabs/fdup
cd fdup
pip install .

Requirements:

  • Python >=3.10
  • numpy >= 1.21.3
  • numba >= 0.55.0
  • rasterio >= 1.3.0

Python API usage

# Import call can take 10-15s since all @njit functions are compiled at import time
from fdup.upscalers import DMM, NSA, COTAT

# DMM
dmm = DMM()
dmm.load_flowacc("flowacc.tif")
dmm.upscale(k=20)
dmm.save("out_dmm.tif")

# NSA
nsa = NSA()
nsa.load_flowacc("flowacc.tif")
nsa.upscale(k=20)
nsa.save("out_nsa.tif")

# COTAT
cotat = COTAT()
cotat.load_flowdir("flowdir.tif")
cotat.load_flowacc("flowacc.tif")
cotat.upscale(k=20, area_threshold=10)
cotat.save("out_cotat.tif")

CLI

Besides Python API, fdup features a command-line interface:

fdup --help

DMM

fdup dmm --flowacc flowacc.tif -o out_dmm.tif -k 20

NSA

fdup nsa --flowacc flowacc.tif -o out_nsa.tif -k 20

COTAT

fdup cotat --flowdir flowdir.tif --flowacc flowacc.tif -o out_cotat.tif -k 20 --area-threshold 10

Note: fdup command is only accessible if Python environment with fdup package installed is activated

I/O

  • --flowdir: input fine-resolution D8 flow direction raster file (for COTAT only).
  • --flowacc: input fine-resolution flow accumulation raster file derived from flow direction raster.
  • -o --output: path to output upscaled flow direction file.

Parameters

  • -k: positive integer scaling factor for resulting grid. Output grid cells will be k times larger than input ones. Note: for DMM, k should be an even number.

  • --area-threshold: drainage area (flow accumulation) increase threshold (for COTAT only). Defines when to stop tracing original fine-resolution flow directions: with larger values of threshold the algorithm tends to more often prefer diagonal flow directions (SE, SW, NW, NE) over orthogonal ones (E, S, W, N).

Input data conventions

The tool works with ESRI-style D8 flow direction encoding for input as well as output flow directions.

For input flow accumulation, the supported data types are uint32, float32, float64/double

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

fdup-0.1.1.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

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

fdup-0.1.1-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

Details for the file fdup-0.1.1.tar.gz.

File metadata

  • Download URL: fdup-0.1.1.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for fdup-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aeaf91544935720f56b8535afe27fd03d0cd402d90cea4f85c5dc35c3b22e5b3
MD5 6ef111766e62d92072aa34edc4ee8373
BLAKE2b-256 2bd89c44b4a41a0f7b3752d4b72acd50238176d8267c0d566c23db6089f191af

See more details on using hashes here.

File details

Details for the file fdup-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fdup-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 27.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for fdup-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e93e01d46b56dac153e3adfe55b76ba51d51e90a0f3b85cb3d2185fc27d93e9
MD5 15e6aced19a023f30ed85ffa9a1393c3
BLAKE2b-256 5ad5c008e049552dfd7571a6af1f42fdc27cf6144ba90d68438ccf54524e23a6

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