Skip to content

Fixes #560: weighted A* pathfinding with friction surface#862

Merged
brendancol merged 3 commits intomasterfrom
fixes-560-weighted-astar-pathfinding
Feb 23, 2026
Merged

Fixes #560: weighted A* pathfinding with friction surface#862
brendancol merged 3 commits intomasterfrom
fixes-560-weighted-astar-pathfinding

Conversation

@brendancol
Copy link
Contributor

Summary

  • Binary min-heap: replaces the O(h×w) open-list scan in _a_star_search with O(log n) heap operations (reused from cost_distance)
  • Friction weighting: a_star_search() accepts an optional friction DataArray; edge costs become geometric_distance × mean_friction_of_endpoints, matching the cost_distance() cost model
  • Cellsize-scaled output: path costs are now spatial distances (cellsize per cardinal step) instead of pixel-space distances
  • Notebook: rewritten to demonstrate unweighted vs weighted A* on generated terrain with slope-derived friction, including validation against cost_distance()

Test plan

  • pytest xrspatial/tests/test_pathfinding.py -v — 10 tests pass (4 existing updated for cellsize scaling + 6 new weighted tests)
  • pytest xrspatial/tests/test_cost_distance.py -v — 19 tests unchanged, all pass
  • jupyter nbconvert --execute docs/source/user_guide/pathfinding.ipynb — executes cleanly, cost_distance validation prints Match: True

Replace the O(h*w) open-list scan with a binary min-heap (reused from
cost_distance) and add optional friction weighting to a_star_search().
Edge costs now use cellsize-scaled spatial distances instead of pixel-
space distances, and when a friction surface is provided the cost model
matches cost_distance (geometric_distance * mean_friction_of_endpoints).
Sparse dask A* loads chunks on demand via LRU cache so pathfinding
works on datasets that don't fit in RAM. CuPy falls back to the
existing numpy kernel with CPU↔GPU transfers.
Add backend support table to docstring and user guide notebook,
dask out-of-core example, and CPU-fallback symbol in README matrix.
@brendancol brendancol merged commit 260656c into master Feb 23, 2026
10 checks passed
@brendancol brendancol deleted the fixes-560-weighted-astar-pathfinding branch February 25, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant