Skip to content

Releases

v0.3.0

Choose a tag to compare

@github-actions github-actions released this 25 Nov 20:23

Full Changelog: v0.2.2...v0.3.0

v0.2.2

Choose a tag to compare

@github-actions github-actions released this 17 Nov 01:29

Full Changelog: v0.2.1...v0.2.2

v0.2.1

Choose a tag to compare

@github-actions github-actions released this 15 Nov 04:24

Full Changelog: v0.2.0...v0.2.1

v0.2.0

Choose a tag to compare

@github-actions github-actions released this 15 Nov 02:47

Full Changelog: v0.1.0...v0.2.0

v0.1.0

Choose a tag to compare

@github-actions github-actions released this 14 Nov 17:36

First release of vgi-hydrology, a Python VGI worker that delineates upstream catchments from a DEM and summarizes their land cover, directly from SQL (DuckDB 2.0 / Haybarn with the vgi extension).

Functions

  • hydrology.main.catchments((SELECT station_id, x, y FROM stations), dem := ..., input_crs := ..., snap_radius_m := ..., min_stream_area_m2 := ...) — independently delineated upstream catchment polygons (WKB) per station from a depression-filled D8 network (PyFlwDir), with area, selected outlet and edge/missing-data completeness flags. Optional Euclidean stream-cell outlet snapping.
  • hydrology.main.landcover((SELECT station_id, geometry_wkb FROM catchments), raster := ..., geometry_crs := ...) — categorical land-cover class counts, areas and coverage fractions per polygon (pixel-centre inclusion, no interpolation of classes).
  • hydrology.main.demo_input — one demo monitoring station; a synthetic DEM and land-cover raster ship inside the wheel, so the demo needs no data or credentials.

Composed examples

  • Dominant upstream class per nested gauge (on catchments): delineate four gauges, feed the polygons to landcover, join back and arg_max by area — class 10 at west, class 20 at east, mid and outlet.
  • Intervening drainage land cover (on landcover): add a mid-valley gauge to demo_input, delineate both nested catchments, and subtract per class to get the area draining only to the outlet (1,500 m² class 10, 1,800 m² class 20).

Install / quick start

Requires Python 3.13+ and uv.

git clone --branch v0.1.0 https://github.com/Query-farm/vgi-hydrology.git
cd vgi-hydrology
uv sync --locked
make demo
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
  WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
ATTACH 'hydrology' (TYPE vgi,
  LOCATION '/absolute/path/to/vgi-hydrology/.venv/bin/vgi-hydrology-worker');
SELECT * FROM hydrology.main.catchments((SELECT * FROM hydrology.main.demo_input));

The signed wheel and sdist (cosign bundles, build provenance) are attached below. Not published to PyPI.

Known limits

  • DEM must be north-up, projected, metre units; land cover must be a north-up categorical raster in a projected metre CRS. Pass dem_crs from catchments as geometry_crs to landcover.
  • Default window limits of 2 million cells for DEM and land cover.
  • Upstream drainage analysis only — not flood inundation, hydraulic routing, discharge prediction or pollutant transport. DEM conditioning and local validation are dataset-specific.
  • Outlet snapping is Euclidean; inspect snapped outlets in ambiguous valleys. Catchments touching the DEM edge or nodata are flagged as potentially incomplete.
  • The first routing call in a fresh worker process pays a few seconds of Numba JIT compile.