Skip to content

Add hypsometric_integral to zonal module#1073

Open
brendancol wants to merge 9 commits intomasterfrom
feature/hypsometric-integral
Open

Add hypsometric_integral to zonal module#1073
brendancol wants to merge 9 commits intomasterfrom
feature/hypsometric-integral

Conversation

@brendancol
Copy link
Contributor

Summary

  • Adds hypsometric_integral(zones, values) to xrspatial/zonal.py computing HI = (mean - min) / (max - min) per zone, painted back to a raster
  • All four backends implemented: numpy, cupy, dask+numpy, dask+cupy
  • Exposed via .xrs.zonal_hypsometric_integral() accessor and top-level xrspatial namespace
  • Supports vector zone inputs (GeoDataFrame, list of geometry/value pairs)

Test plan

  • 29 tests across all backends (numpy, cupy, dask+numpy, dask+cupy)
  • Edge cases: flat zones, NaN values, single-cell zones, all-NaN zones, nodata=None
  • Accessor method test
  • Vector zones (list of pairs) test
  • Existing zonal test suite passes (no regressions)
  • Top-level import verified

Add column/rasterize_kw params, fix accessor namespace to .xrs,
clarify nodata semantics, specify float64 output dtype, add
list-of-pairs zones support, note dask chunk alignment strategy.
Wire up _hi_dask_numpy (per-block aggregation + reduce + map_blocks
paint-back) and _hi_dask_cupy (host transfer delegate) backends.
Add .xrs.zonal_hypsometric_integral() accessor method, top-level
import in __init__.py, accessor test, and vector-zones test.
Add _to_numpy helper that handles cupy, dask, and numpy backends
correctly, avoiding implicit cupy-to-numpy conversion error.
@github-actions github-actions bot added the performance PR touches performance-sensitive code label Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant