Problem
TIFF tag 274 (Orientation) values 1-8 specify how rows and columns map to display orientation. The default is 1 (top-left). The reader never reads this tag, so files with non-default orientation decode to silently flipped or rotated arrays — pixel values are correct, geometry is wrong.
Where
xrspatial/geotiff/_header.py and xrspatial/geotiff/_geotags.py — Orientation tag is not in the parse list, and no read path applies an orientation transform.
Repro
import tifffile, numpy as np
from xrspatial.geotiff import open_geotiff
arr = np.arange(64, dtype='uint16').reshape(8, 8)
tifffile.imwrite('/tmp/oriented.tif', arr, extratags=[(274, 'H', 1, 4, True)]) # 4 = bottom-left
# Reference using a known-correct decoder
print(tifffile.imread('/tmp/oriented.tif')) # flipped vertically per orientation=4
# xrspatial returns the raw row order, ignoring orientation
print(open_geotiff('/tmp/oriented.tif').values[0])
Fix sketch
After decode, apply the orientation transform per the TIFF 6.0 spec table:
| Value |
Transform |
| 1 |
identity |
| 2 |
flip horizontally |
| 3 |
rotate 180 |
| 4 |
flip vertically |
| 5 |
transpose |
| 6 |
rotate 90 CW |
| 7 |
transverse |
| 8 |
rotate 90 CCW |
Coordinate axes need to swap for transposed orientations (5-8). Most camera-produced TIFFs use 1-4; values 5-8 are rare.
Severity
Silent geometric error, not numerical drift. Pixel values are correct but in the wrong positions.
Problem
TIFF tag 274 (Orientation) values 1-8 specify how rows and columns map to display orientation. The default is 1 (top-left). The reader never reads this tag, so files with non-default orientation decode to silently flipped or rotated arrays — pixel values are correct, geometry is wrong.
Where
xrspatial/geotiff/_header.pyandxrspatial/geotiff/_geotags.py— Orientation tag is not in the parse list, and no read path applies an orientation transform.Repro
Fix sketch
After decode, apply the orientation transform per the TIFF 6.0 spec table:
Coordinate axes need to swap for transposed orientations (5-8). Most camera-produced TIFFs use 1-4; values 5-8 are rare.
Severity
Silent geometric error, not numerical drift. Pixel values are correct but in the wrong positions.