Skip to content

Add raster-based dasymetric mapping module#936

Merged
brendancol merged 1 commit intomasterfrom
worktree-issue-930
Mar 4, 2026
Merged

Add raster-based dasymetric mapping module#936
brendancol merged 1 commit intomasterfrom
worktree-issue-930

Conversation

@brendancol
Copy link
Contributor

Closes #930.

Summary

  • Adds disaggregate() for redistributing zone-level values (e.g. population per census tract) onto a finer raster grid using ancillary weights. Three methods: 'binary', 'weighted', 'limiting_variable'. All four backends supported for binary/weighted; limiting_variable is numpy-only.
  • Adds pycnophylactic() implementing Tobler's (1979) smooth interpolation — iterative Laplacian smoothing with mass correction that preserves zone totals. Numpy and cupy (CPU fallback) supported; dask raises NotImplementedError since the algorithm is inherently iterative.
  • Adds validate_disaggregation() to check that zone totals in a result match the input values within tolerance. Works across all four backends.
  • Accessor methods on .xrs for disaggregate and pycnophylactic.
  • API docs, changelog entry, and user guide notebook with synthetic data demos.

Test plan

  • pytest xrspatial/tests/test_dasymetric.py -v — 51 tests pass
  • Conservation property verified for all methods (sum(result[zone]) == values[zone])
  • Cross-backend parity: numpy vs dask+numpy, numpy vs cupy, numpy vs dask+cupy
  • Edge cases: NaN zones/weights, zero-sum zones, negative weights, nodata_zone, missing zone IDs, single-pixel zones
  • Validation: wrong types, wrong dims, shape mismatch, invalid method
  • Import works: from xrspatial import disaggregate, pycnophylactic, validate_disaggregation

Adds disaggregate(), pycnophylactic(), and validate_disaggregation()
for redistributing zone-level values onto finer raster grids.

disaggregate supports three methods (binary, weighted, limiting_variable)
across all four backends (numpy, cupy, dask+numpy, dask+cupy).
pycnophylactic implements Tobler's smooth interpolation with iterative
Laplacian smoothing and mass correction (numpy/cupy).
validate_disaggregation checks that zone totals are preserved within
tolerance across all backends.

51 tests covering known values, conservation, edge cases, cross-backend
parity, and input validation.
@github-actions github-actions bot added the performance PR touches performance-sensitive code label Mar 4, 2026
@brendancol brendancol merged commit 9c763d0 into master Mar 4, 2026
11 checks passed
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.

Raster-based dasymetric mapping / spatial disaggregation

1 participant