Skip to content

Commit b157090

Browse files
authored
Fixes #880: replace single-chunk rechunk in cost_distance with iterative tile Dijkstra (#888)
cost_distance() had two OOM paths when max_cost=inf (the default) or the implied overlap exceeded chunk dimensions: (1) rechunking both arrays into a single chunk, materialising the full raster, and (2) allocating a full-size heap inside the kernel. Replace the single-chunk fallback with a streaming boundary-only iterative Dijkstra that processes tiles one at a time, storing only 1-pixel-wide boundary strips between iterations — O(sqrt(N)) memory instead of O(N). Algorithm: Gauss-Seidel forward/backward sweeps seed each tile's Dijkstra from converged neighbour boundaries (cardinal + diagonal along shared edges + corner seeds for 8-connectivity), iterate until no boundary changes, then lazily assemble the final result via da.map_blocks.
1 parent e94a9b2 commit b157090

2 files changed

Lines changed: 686 additions & 9 deletions

File tree

0 commit comments

Comments
 (0)