Problem
TIFF allows a different bit depth per sample: BitsPerSample is a count-SamplesPerPixel array. The reader uses only bps[0] everywhere and assumes uniform bit width across bands.
Real-world example: a TIFF with SamplesPerPixel=4, BitsPerSample=(16, 16, 16, 8) (RGB at 16-bit, alpha at 8-bit). xrspatial decodes all four bands as 16-bit, producing garbage in the alpha band.
Where
xrspatial/geotiff/_dtypes.py and xrspatial/geotiff/_reader.py — bit-depth dispatch.
Fix sketch
Two reasonable options:
- Reject mixed bit depths with a clear error message.
- Decode each band at its own bit width into a separate array, then promote to a common dtype.
Option 1 is fine for now since this is rare in practice.
Severity
Low — uncommon in practice, but silent data corruption when it happens.
Problem
TIFF allows a different bit depth per sample:
BitsPerSampleis a count-SamplesPerPixelarray. The reader uses onlybps[0]everywhere and assumes uniform bit width across bands.Real-world example: a TIFF with
SamplesPerPixel=4,BitsPerSample=(16, 16, 16, 8)(RGB at 16-bit, alpha at 8-bit). xrspatial decodes all four bands as 16-bit, producing garbage in the alpha band.Where
xrspatial/geotiff/_dtypes.pyandxrspatial/geotiff/_reader.py— bit-depth dispatch.Fix sketch
Two reasonable options:
Option 1 is fine for now since this is rare in practice.
Severity
Low — uncommon in practice, but silent data corruption when it happens.