Skip to content

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

Merged
brendancol merged 3 commits into
mainfrom
deep-sweep-api-consistency-reproject-2026-05-10
May 11, 2026
Merged

reproject: align attrs['vertical_crs'] with geotiff (EPSG int)#1574
brendancol merged 3 commits into
mainfrom
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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request addresses API consistency between xrspatial.reproject.reproject() and xrspatial.geotiff.open_geotiff() by making reproject() write attrs['vertical_crs'] as an EPSG integer code (matching the GeoTIFF reader) instead of a friendly string token, while preserving the token under a new attrs['vertical_datum'].

Changes:

  • Introduced a token→EPSG mapping for vertical datums and updated reproject() to emit EPSG ints in attrs['vertical_crs'], plus attrs['vertical_datum'] for the original token.
  • Updated and added tests to assert the new attribute semantics for EGM96 / EGM2008 / ellipsoidal cases.
  • Logged the sweep state update for the API consistency pass.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
xrspatial/reproject/__init__.py Emit EPSG integer vertical CRS codes (and preserve friendly token under vertical_datum) to align with GeoTIFF conventions.
xrspatial/tests/test_reproject.py Update existing assertion and add coverage ensuring vertical_crs is an EPSG int and vertical_datum preserves the token.
.claude/sweep-api-consistency-state.csv Record inspection state and notes for the reproject module consistency sweep.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread xrspatial/reproject/__init__.py
Comment thread xrspatial/reproject/__init__.py
Address PR #1574 review:
- reproject() now raises ValueError if src_vertical_crs or
  tgt_vertical_crs is set to a token outside _VERTICAL_DATUM_EPSG.
  The previous .get() silently wrote None to attrs['vertical_crs']
  for typos / unsupported values, producing outputs with
  vertical_datum set but vertical_crs missing.
- Update the docstring's Returns section to say the vertical attrs
  are written whenever tgt_vertical_crs is set (not only "if a
  vertical transformation was applied"), matching the actual
  behaviour when src == tgt or only the target is provided.
- Add test_unknown_vertical_crs_raises covering both kwargs.
@brendancol brendancol merged commit 47d6903 into main May 11, 2026
11 checks passed
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)

2 participants