Fix D-inf flow direction odd facet decomposition (Tarboton 1997)#1005
Merged
brendancol merged 3 commits intomasterfrom Mar 14, 2026
Merged
Fix D-inf flow direction odd facet decomposition (Tarboton 1997)#1005brendancol merged 3 commits intomasterfrom
brendancol merged 3 commits intomasterfrom
Conversation
Odd facets (1,3,5,7) incorrectly used consecutive CCW neighbor pairs (e.g. facet 1: e1=NE, e2=N) with diagonal-based d1 distances. Tarboton requires e1=cardinal, e2=diagonal with alternating angle sign (e.g. facet 1: e1=N, e2=NE, angle=pi/2-r). Even facets were already correct. Fixed both CPU and GPU kernels.
- Increase GPU scanline fill MAX_ISECT from 512 to 2048 to handle dense polygon inputs (1000+ irregular polygons would silently drop edges, causing wrong pixel values and missing coverage) - Add host-side warning when active edge count exceeds the GPU limit - Vectorize _classify_geometries using shapely 2.0 array ops instead of per-geometry Python calls (178x faster for the classification step) - Defer bounds computation in _parse_input so callers who supply explicit bounds skip the unnecessary bbox scan - Add cross-library rasterizer benchmark (benchmarks/rasterizer_benchmarks.py) covering 10 geometry types with consistency checks and markdown output
…ology API - Move D-inf flow accumulation from flow_accumulation.py into flow_accumulation_dinf.py with its own test file - Update basin, watershed, stream_order, and stream_order_mfd to use D8 flow direction consistently - Add flow_accumulation_dinf to public API and docs - Simplify flow_accumulation.py to D8-only logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_cpu) and GPU (_gpu) kernels.test_odd_facet_1_tarboton,test_odd_facet_7_tarboton) and a full-grid comparison against a pure-Python reference Tarboton (test_reference_tarboton_agreement).Test plan
test_flow_direction_dinf.pypass (numpy, dask, cupy, dask+cupy)