feat: add opt-in rasterization tiles#1166
Open
stanbot8 wants to merge 2 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1166 +/- ##
==========================================
+ Coverage 92.44% 92.55% +0.11%
==========================================
Files 51 51
Lines 7820 7900 +80
==========================================
+ Hits 7229 7312 +83
+ Misses 591 588 -3
🚀 New features to boost your workflow:
|
stanbot8
force-pushed
the
feat/987-raster-output-tiling
branch
from
July 24, 2026 20:26
8c23041 to
aab46d8
Compare
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.
2 implementations exist. Both contain the same shared commit sequence. This implementation adds optional output tiles after the label dtype fix. The other implementation stops after the shared sequence and the label dtype fix with 1 output canvas. Compare the limitations.
Summary
Add optional output tiles to rasterization.
tile_size=Nonekeeps the current behavior. A positivetile_sizelimits each spatial output chunk. It also limits each Datashader canvas for points and shapes. This branch fixes the label-count failure. Closes #987.Design
Images and labels pass bounded output chunks to the affine transform. Points use half-open internal tile bounds. Shapes use a 1-pixel halo and crop it. One spatial index selects the shapes for each tile. Sorted positions preserve Datashader
firstsemantics.The implementation changes
src/spatialdata/_core/operations/rasterize.py.Benchmark
The benchmark rasterized a
3 × 4096 × 4096float32image. The output size was192 MiB. Each result was stored in a memory-mapped file with single-threaded Dask. The table shows medians from7runs on an Intel Core i7-8700K.tile_sizeNone192 MiB2574.400 s398.2 MiB102412 MiB7564.009 s-8.9%221.2 MiB44.5%5123 MiB12203.682 s-16.3%216.2 MiB45.7%2560.75 MiB26284.500 s+2.3%218.5 MiB45.1%For this workload,
tile_size=1024reduced the peak RSS increase by44.5%.The image benchmark source and recorded results use candidate
aab46d8ec96acb9213a51cd244397a12a2f0579f.An indexed-shape benchmark used
4096shapes and64tiles. The index reduced the Datashader input from262145to5042rows (98.1%). It reduced the largest tile input from4096to81shapes (98.0%). The median time fell from1.443 sto0.957 s(33.7%). Both outputs had the same checksum. See the shape benchmark source and recorded results.Benchmark commands
Limitations
Smaller tiles create more graph tasks. A shape that crosses tile boundaries is rendered in each intersecting tile.
Tests
Raster tests verify bounded chunks for 2D images, 2D labels, and 3D multiscale images. Point tests cover internal tile edges, global maximum bounds, and uneven tile sizes. Shape tests cover overlaps and categorical channels. Each tiled result is identical to the untiled result.
The rasterization test file passes with
14tests. The complete suite passes with1371tests,7skips, and1expected failure.The tests are in
tests/core/operations/test_rasterize.py.Commands