Skip to content

feat: Add a GeoKey-to-CRS conformance corpus and CT method table - #84

Merged
kylebarron merged 11 commits into
mainfrom
kyle/crs-conformance-corpus
Oct 26, 2026
Merged

kylebarron merged 11 commits into
mainfrom
kyle/crs-conformance-corpus

Conversation

@kylebarron

Copy link
Copy Markdown
Member

Note

This PR was written by Claude (Claude Code), not by @kylebarron.

Adds crs/, a conformance corpus for readers that build a CRS from GeoTIFF GeoKeys, with GDAL/PROJ as the oracle. Consumers: async-geotiff (Python) now, the deck.gl-raster GeoTIFF package (TypeScript) later. Design: dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md in async-geotiff.

What is in it

  • crs/cases.py: 98 cases. One per ProjCoordTransGeoKey code GDAL can write, each distinct key arrangement GDAL emits for it, US survey and international feet, grads, EPSG-coded and user-defined datums and ellipsoids, a sphere, TOWGS84, Greenwich/named/user-defined/EPSG-coded prime meridians, ProjectionGeoKey without a CT code, ESRI PE String citations, 46 EPSG codes plus ESRI:54009, and Equal Earth (which GDAL cannot encode).
  • crs/generate_crs.py (pixi run generate-crs): writes each fixture with rasterio (or tifffile for one hand-built key set), reads it back with GDAL_PAM_ENABLED=NO, and writes crs/manifest.json: the raw GeoKeys GDAL wrote, GDAL's PROJJSON and proj4, a name-free core in degrees/metres for readers without a PROJ database, and a test point. Deterministic; scripts/check.sh now runs it.
  • crs/epsg/*.json: cached epsg.io responses for the coded cases, so TypeScript tests can run offline.
  • crs/geotiff-ct-methods.json: for every CT code, the PROJ/EPSG method and how each parameter is read from GeoKeys (key fallback order, kind, default), transcribed from libgeotiff GTIFFetchProjParms and GDAL GTIFGetOGISDefn with line citations, plus the three variant rules (Mercator A/B, Polar Stereographic A/B as PROJ decides it, HOM A/B/Laborde as separate codes). Tests check it against what GDAL actually read back for each fixture.
  • crs/README.md: schema of the manifest and the table, how to read the table, and the GDAL/PROJ behaviours the corpus documents.
  • Tests: helpers, every fixture's raw keys equal its manifest row, no PROJ-string case collapsed to an EPSG code, exactly two flagged rows, table and manifest cover each other.

Flagged rows (recorded, not tested)

  • eqearth: GDAL writes no GeoKeys.
  • stere_polar_scaled_wkt: Polar Stereographic off the pole with scale 0.9 reads back as a non-EPSG Polar_Stereographic method PROJ cannot export.

Notes

  • pyproj is now an explicit pypi dependency (it was transitive). The lock was updated with pixi 0.82.1, matching CI.
  • scripts/info.sh skips crs/; the manifest documents those files.
  • Four rows (tmerc_towgs84, omerc_variant_a, omerc_variant_b, somerc) need GeoKeys that async-tiff exposes only from feat: Expose GeogTOWGS84GeoKey and ProjRectifiedGridAngleGeoKey async-tiff#368 onward.
  • The pinned environment is GDAL 3.12.4 / PROJ 9.8.1 / pyproj 3.8.0; the manifest records this under generator.

🤖 Written by Claude Code

🤖 Generated with Claude Code

kylebarron and others added 8 commits October 26, 2026 11:42
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…pers

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
97 GDAL-written fixtures, the manifest of GeoKeys written and CRS read
back, and cached epsg.io JSON for the coded cases. The generator sends a
User-Agent because epsg.io rejects urllib's default one.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Transcribed from libgeotiff GTIFFetchProjParms and GDAL GTIFGetOGISDefn
with line citations; method names and parameter sets are checked against
what GDAL read back for each fixture. Adds an eqc_lat0 fixture to pin
how PROJ treats the latitude of origin for Equidistant Cylindrical.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Also formats the new modules with ruff format.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Review findings: libgeotiff reads ProjScaleAtNatOrigin only for
CT_Mercator, and PROJ sets both Polar Stereographic axes south or north
by the sign of the latitude. The README also gains a comparison rule for
the core (match by EPSG code, dropped zeros, tolerance).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Comment thread crs/README.md Outdated

GDAL/PROJ is the oracle. For every case, GDAL writes the file and then reads it back; the manifest records both the raw GeoKeys GDAL wrote and the CRS GDAL/PROJ reads from them. A reader is conformant when, for every tested fixture, the CRS it builds equals the one in the manifest.

Consumers today: [async-geotiff](https://github.com/developmentseed/async-geotiff) (Python, pyproj) and the GeoTIFF package in [deck.gl-raster](https://github.com/developmentseed/deck.gl-raster) (TypeScript, no PROJ database). The design is written up in async-geotiff under `dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md`.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We should include the design for the conformance corpus as a spec in this repo, checked in

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note

This comment was written by Claude (Claude Code), not by @kylebarron.

Done in 28fc95b: the design document is checked in as crs/DESIGN.md (verbatim copy of the async-geotiff spec, which also covers the builder that consumes this corpus), and this README paragraph now links to it.

🤖 Written by Claude Code

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note

This comment was written by Claude (Claude Code), not by @kylebarron.

Moved to dev-docs/specs/2026-10-26-geokey-crs-conformance-design.md in the latest commit; the README link follows it.

🤖 Written by Claude Code

kylebarron and others added 3 commits October 26, 2026 12:24
PROJ's projected coordinates differ in the last digits between macOS
arm64 and Linux x86_64, which made check.sh fail in CI. Round x and y
to millimetres, and keep the committed value when a regeneration moves
it by less than a millimetre so a rounding boundary cannot flip either.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…rounding

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@kylebarron
kylebarron merged commit 35da663 into main Oct 26, 2026
1 check passed
@kylebarron
kylebarron deleted the kyle/crs-conformance-corpus branch October 26, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant