Skip to content

Commit ee6cd52

Browse files
authored
Fix scanline row gaps, speed up rasterize, add resolution/like/merge (#991)
* Fix scanline gap bug and optimize rasterize performance The scanline fill had a row-clamping bug (floor(r1)-1 instead of ceil(r1)-1) that left every other row empty in curved polygons. Also adds three performance improvements: - Vectorized edge extraction via shapely 2.0 array ops (~13x faster) - Sorted edge table with binary search in scanline kernel (~7-50x faster) - Single-pass geometry classification to avoid redundant iteration * Add resolution, like, and merge parameters to rasterize - resolution: derive width/height from a pixel size (scalar or (dx, dy) tuple) - like: copy grid dimensions, bounds, and dtype from a template DataArray - merge: configurable overlap strategy (last/first/max/min/sum/count) with per-pixel dispatch via _merge_pixel helpers (CPU and GPU) - geometry-ID-based scanline ordering so overlap merge follows input order * Active edge list, written-mask, GeometryCollection, lazy cuda - Scanline kernel now maintains an active edge list instead of scanning all edges up to the binary-search cutoff. For 2000 small circles this drops edge checks from 19.8M to 40K (497x reduction). - Replaced NaN sentinel with a separate int8 written-mask so merge modes (first/sum/etc.) work correctly when burning NaN values. - GeometryCollections are recursively unpacked instead of silently dropped. - GPU kernels are compiled lazily on first use_cuda=True call instead of at import time (rasterize.py no longer does `from numba import cuda` at module level). * Vectorize point/line extraction, clip lines to bounds, CSR GPU scanline Point and line extraction now use shapely 2.0 vectorized ops (get_parts/get_coordinates) instead of Python loops. Line segments are clipped to raster bounds via Liang-Barsky before Bresenham, cutting iteration from ~20K to ~100 steps for far-off-screen lines. GPU scanline kernel reads active edges from a precomputed CSR structure instead of binary-searching + scanning dead edges. * Renumber user guide notebooks to remove duplicates Three notebooks shared prefix 17 and two shared 25. Spread the triple-17s across 17-19 and shift everything after by +2. Gave the unnumbered zonal_crosstab notebook prefix 30.
1 parent 02e5b01 commit ee6cd52

15 files changed

+1360
-532
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/user_guide/25_Rasterize.ipynb

Lines changed: 0 additions & 115 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)