Skip to content

fix: support Cylindrical Equal Area CRSes - #791

Merged
kylebarron merged 4 commits into
mainfrom
kyle/wkt-epsg-fallback
Nov 3, 2026
Merged

kylebarron merged 4 commits into
mainfrom
kyle/wkt-epsg-fallback

Conversation

@kylebarron

@kylebarron kylebarron commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Note

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

GeoTIFFs in a Cylindrical Equal Area CRS without an EPSG code, such as the World Cylindrical Equal Area (ESRI:54034) COG in #649, failed to load with Unsupported coordinate transformation type: 28. GDAL writes these as a user-defined projected CRS with ProjMethodGeoKey 28, libgeotiff's CT_CylindricalEqualArea, which crsFromGeoKeys didn't map. The file has no WKT and no EPSG code, so the epsgResolver fallback #649 proposes can't help it; parseWkt doesn't throw for an unknown method in any case, since that failure surfaces later, in proj4().

Mapping the GeoKeys alone isn't enough either: proj4 registers this projection only as cea, which reads its standard parallel from lat_ts, while wkt-parser keeps the WKT/PROJJSON method name and puts the standard parallel in lat1. So EPSG-coded CRSes such as EASE-Grid 2.0 (EPSG:6933) from epsg.io failed too.

Changes

  • crsFromGeoKeys maps ProjMethodGeoKey 28 to a "Lambert Cylindrical Equal Area" conversion, reading the same GeoKeys as libgeotiff.
  • @developmentseed/proj registers proj4's cea under the names wkt-parser gives it, "Lambert Cylindrical Equal Area" (WKT2 and PROJJSON) and "Cylindrical_Equal_Area" (WKT1), with an init that reads the standard parallel from lat1. parse-wkt.ts runs the registration when it loads. It's a workaround until proj4js registers the names and wkt-parser puts the standard parallel in lat_ts.

Tests

Closes #649

🤖 Written by Claude Code

GeoTIFFs in a Cylindrical Equal Area CRS without an EPSG code, such as
World Cylindrical Equal Area (ESRI:54034), failed to load with
"Unsupported coordinate transformation type: 28". GDAL writes these as a
user-defined projected CRS with ProjMethodGeoKey 28, libgeotiff's
CT_CylindricalEqualArea, which crsFromGeoKeys didn't map.

Mapping it to a "Lambert Cylindrical Equal Area" conversion alone isn't
enough: wkt-parser keeps that method name (or "Cylindrical_Equal_Area" in
WKT1), but proj4 registers the projection only as "cea" and reads its
standard parallel from lat_ts, not lat1. parseWkt now renames the method
and copies the standard parallel, which also fixes EPSG-coded CRSes such
as EASE-Grid 2.0 (EPSG:6933) that epsgResolver fetches from epsg.io.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the fix label Oct 23, 2026

@kylebarron kylebarron left a comment

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.

I think we need to overhaul how we handle custom CRSes; this is just a band-aid

@kylebarron

Copy link
Copy Markdown
Member Author

Mapping the GeoKeys alone isn't enough either: proj4 registers this projection only as cea, which reads its standard parallel from lat_ts, while wkt-parser keeps the WKT/PROJJSON method name and puts the standard parallel in lat1. So EPSG-coded CRSes such as EASE-Grid 2.0 (EPSG:6933) from epsg.io failed too.

This feels so hacky :/ is there any less-hacky solution here?

@kylebarron

Copy link
Copy Markdown
Member Author

Note

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

This feels so hacky :/ is there any less-hacky solution here?

The parseWkt block is the hacky part. The GeoKeys half, mapping coordinate transformation 28 as libgeotiff does, isn't. The block covers two gaps in proj4js, and each would be a one-line fix there, following its own pattern:

  • proj4 doesn't know CEA's WKT names. Most proj4 projections also register their WKT method names, for example eqc with 'Equidistant_Cylindrical', aea with 'Albers_Conic_Equal_Area' and stere with 'Polar_Stereographic_variant_B'. But cea registers only ['cea'], so wkt-parser's correct method name, "Lambert Cylindrical Equal Area", doesn't resolve.
  • wkt-parser doesn't move CEA's standard parallel. It puts "Latitude of 1st standard parallel" in lat1, and already copies lat1 into lat_ts for polar stereographic (util.js), whose proj4 implementation reads lat_ts. cea reads lat_ts too, but isn't in that list. wkt-parser 1.6.0, which chore(deps): bump the prod-dependencies group across 1 directory with 18 updates #831 just brought in, still lacks it.

Options:

  1. Fix it upstream (my pick). Add CEA's WKT names to proj4js's cea.js, and add CEA next to polar stereographic in wkt-parser's lat1 -> lat_ts copy. Then delete our block once we bump. Until then, keep the block with a See <upstream PR> link, so it reads as temporary. This needs your OK to file upstream.
  2. Register an alias projection with proj4 instead of rewriting parseWkt's output: cea under its WKT names, with an init that sets lat_ts from lat1. That keeps parseWkt generic, but it's the same shim in another place, and it relies on proj4's projection registry.
  3. Own a PROJJSON -> proj4 table in @developmentseed/proj, keyed by EPSG method name, and use wkt-parser only for WKT1. This is what my Oct 26 CRS audit recommended. It would fix the whole class at once, including eqc's standard parallel and Hotine Oblique Mercator's parameters, not just CEA. But it's a big change and a big review.

🤖 Written by Claude Code

… rewriting parseWkt's output

proj4 knows the projection only as "cea", which reads its standard
parallel from lat_ts; wkt-parser keeps the WKT method name and puts the
standard parallel in lat1. Rather than rewrite parseWkt's output,
register proj4's cea under the WKT method names, with an init that reads
lat1. A workaround until proj4js and wkt-parser handle both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kylebarron

Copy link
Copy Markdown
Member Author

Note

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

Went with option 2 for now, and the upstream fixes are on branches. ea71517f drops the rewrite of parseWkt's output. Instead, @developmentseed/proj registers proj4's cea under the two WKT method names, with an init that reads the standard parallel from lat1. The two PROJ comparison tests fail without the registration.

Upstream:

  • proj4js: register Cylindrical_Equal_Area and Lambert_Cylindrical_Equal_Area on cea.
  • wkt-parser: copy lat1 to lat_ts for Cylindrical Equal Area, as it already does for polar stereographic.

Once those land and we bump, the registration can go.

🤖 Written by Claude Code

@kylebarron kylebarron left a comment

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.

✅

@kylebarron
kylebarron merged commit 062bf1b into main Nov 3, 2026
4 checks passed
@kylebarron
kylebarron deleted the kyle/wkt-epsg-fallback branch November 3, 2026 01:19
alukach added a commit to source-cooperative/cog-viewer that referenced this pull request Nov 4, 2026
…hes (#47)

Disabling every patch and re-testing on 0.9.0 showed these three make no
difference: a deep-zoom Vancouver view and a global Mollweide COG render
identically without them, and the deck.gl-geotiff WKT fallback never ran
(per #39). The deck.gl-raster one also broke culling: it padded each
tile's bounding box to >= 1 common-space unit (~50 km at 49N), so a
static deep zoom selected and fetched ~38k tiles (#41).

Keep the geotiff and proj patches: without them the Colombia CEA COG
(#28) fails. They are fixed upstream in developmentseed/deck.gl-raster#791
but not yet released.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fall back to epsgResolver when parseWkt throws for an unknown projection method

1 participant