Skip to content

Add TPI-based landform classification (#950)#957

Merged
brendancol merged 3 commits into
masterfrom
issue-950
Mar 4, 2026
Merged

Add TPI-based landform classification (#950)#957
brendancol merged 3 commits into
masterfrom
issue-950

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

  • Adds landforms() to xrspatial.terrain_metrics -- the Weiss (2001) 10-class TPI-based landform classification
  • Computes TPI at two configurable neighborhood scales via NaN-aware circular convolution, standardizes to z-scores, then classifies each cell as canyon, midslope drainage, upland drainage, U-shaped valley, plain, open slope, upper slope, local ridge, midslope ridge, or mountain top
  • All four backends work (numpy, cupy, dask+numpy, dask+cupy). TPI-at-radius uses scipy.ndimage.convolve / cupyx.scipy.ndimage.convolve with map_overlap for dask; classification uses xr.where

Test plan

  • Flat surface produces all class 5 (plains)
  • Gaussian peak center classifies as mountain top (class 10)
  • Varied terrain produces multiple distinct classes
  • NaN propagation from input elevation to output
  • Invalid radius parameters raise ValueError
  • Output shape, dims, attrs match input
  • All non-NaN outputs in range 1-10
  • LANDFORM_CLASSES dict covers classes 1-10
  • Numpy vs dask backend agreement (>98% cell match)
  • Slope threshold shifts cells between class 5 and 6
  • Dataset support via @supports_dataset
  • Full existing test suite passes (144 passed, 48 skipped GPU)

Closes #950

Implements the Weiss (2001) 10-class landform classification scheme.
Computes TPI at two neighborhood scales using NaN-aware circular
convolution, standardizes to z-scores, and classifies each cell based
on relative position and slope. Supports all four backends (numpy,
cupy, dask+numpy, dask+cupy).
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label Mar 4, 2026
@brendancol brendancol merged commit 699bca0 into master Mar 4, 2026
11 checks passed
@brendancol brendancol deleted the issue-950 branch May 4, 2026 13:06
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.

Add TPI-based landform classification

1 participant