Skip to content

fix: properly reverse predictor for multi-band planar configuration tiff - #348

Merged
kylebarron merged 5 commits into
mainfrom
fix/multi-band-interleave-pred2
Oct 13, 2026
Merged

kylebarron merged 5 commits into
mainfrom
fix/multi-band-interleave-pred2

Conversation

@weiji14

@weiji14 weiji14 commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Ensure reverse predictor (2 and 3) is properly applied on a band/channel-wise basis (i.e. stride=1) for multi-band, planar configuration TIFFs.

TODO:

Fixes #346, patches #265.

Add test to ensure a multi-band, band-interleaved GeoTIFF with predictor=2 can be read properly. Using sample file at developmentseed/geotiff-test-data#78.
@weiji14 weiji14 self-assigned this Oct 9, 2026
@ds-release-bot ds-release-bot Bot added the fix label Oct 9, 2026
Planar configuration TIFFs should have reverse predictor applied using stride of 1, while chunky config keeps using stride=samples_per_pixel.
Comment thread python/tests/test_tiff.py
# Regression test for
# https://github.com/developmentseed/async-tiff/issues/346
"rasterio",
"uint16_3band_zstd_predictor2",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, error before fix is applied from CI logs at https://github.com/developmentseed/async-tiff/actions/runs/37892107707/job/113695111009?pr=348#step:9:163:

FAILED tests/test_tiff.py::test_read_band_interleaved_tiff_window[rasterio-uint16_3band_zstd_predictor2] - AssertionError: 
Arrays are not equal

Mismatched elements: 9514 / 12288 (77.4%)
Max absolute difference among violations: 298
Max relative difference among violations: 42.
 ACTUAL: array([[[    0,     2,     2, ...,    42,    42,    42],
        [   42,    44,    44, ...,    84,    84,    84],
        [   84,    86,    86, ...,   126,   126,   126],...
 DESIRED: array([[[  0,   2,   4, ..., 122, 124, 126],
        [  0,   2,   4, ..., 122, 124, 126],
        [  0,   2,   4, ..., 122, 124, 126],...
=================== 1 failed, 43 passed, 1 warning in 10.55s ===================

@weiji14
weiji14 marked this pull request as ready for review October 10, 2026 00:30
Comment thread src/tile.rs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geospatial-jeff, see if the changes here make sense to fix #346?

@weiji14

weiji14 commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

I'll give Jeff another day to respond before merging.

@geospatial-jeff geospatial-jeff left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great!

@kylebarron

Copy link
Copy Markdown
Member

Thanks!

@kylebarron
kylebarron merged commit 9a0ebac into main Oct 13, 2026
14 checks passed
@kylebarron
kylebarron deleted the fix/multi-band-interleave-pred2 branch October 13, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tile decoding fails for multi-band, band interleaved tiffs

3 participants