Skip to content

reproject: align attrs['vertical_crs'] with geotiff (EPSG int)#1574

Open
brendancol wants to merge 2 commits intomainfrom
deep-sweep-api-consistency-reproject-2026-05-10
Open

reproject: align attrs['vertical_crs'] with geotiff (EPSG int)#1574
brendancol wants to merge 2 commits intomainfrom
deep-sweep-api-consistency-reproject-2026-05-10

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

  • Fixes reproject: attrs['vertical_crs'] semantics collide with geotiff (string vs EPSG int) #1570: reproject() was writing attrs['vertical_crs'] as a string token ('EGM96', 'EGM2008', 'ellipsoidal'), while xrspatial.geotiff.open_geotiff() writes the same attr as an EPSG integer (e.g. 5773). Same key, incompatible types across two public read/write paths.
  • reproject() now writes the EPSG integer code (5773 / 3855 / 4979) to attrs['vertical_crs'] to match the geotiff convention. The friendly string token is preserved under attrs['vertical_datum'] so the human-readable name is not lost.
  • The src_vertical_crs / tgt_vertical_crs kwargs still accept the string tokens, so call sites do not change.

Behavior change

The type of attrs['vertical_crs'] on reproject() output changes from str to int. Searched the repo: no notebooks, tests, or other modules read this attr off a reproject result, so external blast radius is minimal. The one existing test that asserted the string form was updated.

Test plan

  • Updated TestVerticalShift::test_reproject_egm96_to_ellipsoidal to assert the new EPSG int form
  • Added TestVerticalShift::test_vertical_crs_attr_is_epsg_int covering EGM96 / EGM2008 / ellipsoidal targets
  • pytest xrspatial/tests/test_reproject.py -- 194 pass

xrspatial.geotiff.open_geotiff() writes attrs['vertical_crs'] as an EPSG
integer (e.g. 5773 for EGM96), while reproject() was writing it as a
string token ('EGM96', 'EGM2008', 'ellipsoidal'). Same key, incompatible
types -- breaks cross-module round trips and downstream code that
inspects the attr.

reproject() now writes the EPSG integer code and preserves the friendly
token under attrs['vertical_datum']. The src_vertical_crs / tgt_vertical_crs
kwargs still accept the string tokens, so existing call sites do not
need to change.

Behavior change: attrs['vertical_crs'] on reproject() output is now an
int rather than a string. Searched the repo; no notebooks or other
modules consume this attr.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 11, 2026
@brendancol brendancol requested a review from Copilot May 11, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reproject: attrs['vertical_crs'] semantics collide with geotiff (string vs EPSG int)

1 participant