Skip to content

geotiff: orientation 5-8 on georeferenced TIFFs returns wrong coords behind a warning #1765

Closed

Description

@brendancol

_apply_orientation_with_geo in xrspatial/geotiff/_reader.py (~line 2260) handles TIFF Orientation tag values 5-8 (transpose, 90 CW, transverse, 90 CCW) on georeferenced files by swapping pixel_width and pixel_height in the transform and calling warnings.warn. That swap is not enough. Orientations 5-8 require a per-orientation origin shift plus a rotation that the axis-aligned GeoTransform cannot express, so the returned x/y coords are wrong while the user only sees a warning saying "may need manual adjustment".

Returning wrong georeferenced coords behind a warning is the wrong contract for this module.

Proposed fix:

  • When a file has crs_epsg or crs_wkt set and the Orientation tag is in {5, 6, 7, 8}, raise NotImplementedError with a message naming the orientation value and pointing at the workaround (reproject with another tool, or strip the Orientation tag).
  • Non-georeferenced files keep the existing axis swap. No geographic claims to violate there.

Implementing the correct affine for 5-8 needs a rotation component the rest of the reader does not carry. Failing hard is the honest option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions