Repository navigation
feat(examples): experimental custom projection example with polar stereographic COGs - #694
Merged
Merged
Conversation
Add `examples/experimental/*` to the pnpm workspace and to the docs workflow's example build loop. The loop skips directories without a package.json: `examples/experimental/` itself matches `examples/*/`, and a failed `node -p` would abort the step under `bash -e`. Both hunks are byte-identical to the ones in #647, so the two branches merge cleanly in either order. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Render COGs in arbitrary planar map projections (Arctic and Antarctic polar stereographic, Equal Earth, Web Mercator), with no basemap. Polar data can't be shown in Web Mercator at all, and choosing a projection is routine in GIS workflows. deck.gl merged experimental support for this as `_CustomProjectionView` (visgl/deck.gl#10741), but it ships with deck.gl v10. The example uses a stand-in on deck.gl 9.4's `OrthographicView` with the same options and `{center, zoom}` view state, so moving to the official view is an import swap in the example plus a globe-detection fix in deck.gl-raster (see the README). - `src/custom-projection/`: the view, viewport and controller stand-in. Common space and zoom match upstream, and so do `preproject`, `postUnproject`, `projectFlat` and `projectionSignature`. - `src/projected-cog-layer/`: `ProjectedCOGLayer`, a `COGLayer` that selects tiles in the map CRS and has `RasterLayer` mesh each tile in map meters (`coordinateSystem: "cartesian"`). Domain-aware culling and trimming, pole and antimeridian handling, and LOD measured on screen. - Vector context (coastlines, graticule, domain outline) is projected on the CPU. - Data: GEBCO 2026, the NASA Explorer Base Map (native EPSG:3031), EOxCloudless, and ITS_LIVE ice velocity (EPSG:3031 and EPSG:3413). No library code changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Zooming in over a pole was slow: a view at zoom 8 meshed 1.15M triangles and spent ~26 s in proj4. The reprojector measures error in source pixels as if they were square, but lng/lat pixels near a pole are only cos(lat) as wide as they are tall on a polar map, so it kept splitting triangles to fix sub-screen-pixel column errors. - Stretch each geographic tile's pixel grid horizontally by the pixels' aspect ratio on the map before meshing (columnErrorScale). RasterLayer only uses `width` to size the mesh grid, so passing width * scale with matching transforms reweighs column error without changing UVs. The ratio is measured in the output map, so it also holds for Equal Earth. - Stop meshing geographic tiles at 89.5° instead of one row from the pole, which halves the remaining pole triangles. Over the pole at zoom 8: 1.15M -> 31k triangles, ~26 s -> 0.7 s of meshing. Visible map-space error is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron
enabled auto-merge (squash)
October 7, 2026 21:21
kylebarron
disabled auto-merge
October 7, 2026 21:22
This was referenced Oct 7, 2026
Closed
kylebarron
added a commit
that referenced
this pull request
Nov 13, 2026
…'s crs-based API (#882) > [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. deck.gl published [`10.0.0-alpha.1`](https://github.com/visgl/deck.gl/releases/tag/v10.0.0-alpha.1). Its experimental `_CustomProjectionView` API has changed since the custom projection example copied it in October (#694). This moves the example's deck.gl 9.4 stand-in to the alpha.1 API, so the example shows how upstream works now. The example stays on deck.gl 9.4, and nothing under `packages/` changes. Ref #695 ### What changed upstream | | October (visgl/deck.gl#10741) | `10.0.0-alpha.1` | | --- | --- | --- | | Projection input | `projection: {forward, inverse}`, `fromCrs`, `toCrs` | **`crs`**: an EPSG code, PROJ string, WKT or PROJJSON, resolved by math.gl's `projectionEngine.getCRS` | | Resolution | synchronous | **asynchronous**: `view.initialize()`, which `Deck` awaits | | World coordinates | `fromCrs` | **always WGS84** | | Domain | `fromBounds` | **set by the projection**: `crs.converter.WGS84.normalize` | | Conversions | `viewport.preproject` / `postUnproject` | `viewport.crs.converter.WGS84.from` / `to` | ### What changes in the example - **The stand-in** (`src/custom-projection/`) takes a `crs` and resolves it with `@math.gl/geospatial` `5.0.0-beta.8`, the version alpha.1 pins, through a cached `resolveCRS`. The viewport exposes `crs`, and `projectionSignature` is `[crs.signature, resolution]`. It still differs from upstream in three ways: - top-down camera only; - meter-based CRSs only, because deck.gl 9.4's `Viewport` constructor calls `projectFlat` before a subclass can store a per-CRS scale; - `project` and `unproject` stay in map meters. - **`ProjectedCOGLayer`** converts through `viewport.crs.converter.WGS84`, and takes its lng/lat domain from the CRS's `normalize` clamp. It no longer has a `fromBounds` prop, and the presets no longer carry one. - **The app** resolves the selected preset's CRS before handing the view to `DeckGL`, because deck.gl 9.4 doesn't await `initialize()`. Until the new CRS resolves, the previous projection stays on screen, so `DeckGL` never remounts. - **The README** says how to move the example to deck.gl v10. - **`examples/_shared`** now declares `@math.gl/web-mercator: ^4.1.0`. Without it, pnpm resolved `@deck.gl/mapbox`'s `@math.gl/web-mercator` peer (range `^4.1.0`) to the new 5.0 beta for every example with a MapLibre overlay. ### Visible change The polar maps now reach math.gl's extent, 60° past the equator, instead of the example's 20°. The default views look the same. <!-- before/after screenshots --> ### Checks math.gl's conversions match proj4's to within a micrometer at sample points inside each preset's extent, for all four presets. COG range requests per view, in headed Chrome: | View | `main` | This PR | | --- | --- | --- | | Arctic, default | 10 | 10 | | Antarctic, default | 10 | 10 | | Equal Earth, default | 4 | 4 | | Web Mercator, default | 8 | 8 | | Antarctic, NASA basemap and ITS_LIVE | 13 | 13 | | Arctic, zoom 0.6 | 3 | **13** | | Antarctic, zoom 0.6 | 4 | **14** | Every view finished loading in under 8 seconds, with no new console messages. - **Switching projections:** switching five times, 40 ms apart, kept one `Deck` instance and only custom projection viewports. - **Cursor:** off the map (above, below or beside it) it reads "—". Beside the Equal Earth and Web Mercator maps, math.gl's inverse returns a wrapped longitude instead of throwing, so the stand-in keeps the October stand-in's round-trip check. The example's main bundle chunk grows from 1,592 KB to 1,801 KB, **+67 KB gzipped**, all of it math.gl's projection engine. Apache Arrow isn't bundled. The example's 56 tests pass, and so do `pnpm -r --filter=!docs typecheck` and `pnpm check`. 🤖 Written by [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I noticed and am excited about upstream deck.gl support for custom projections (visgl/deck.gl#10739).
I asked Claude to vendor the current upstream implementation (from visgl/deck.gl#10740 and visgl/deck.gl#10741) and write an experimental example. This PR should show off what we'll support in deck.gl-raster once upstream v10 deck.gl is released.
Note
This PR was written by Claude (Claude Code) on behalf of @kylebarron, not by @kylebarron.
Adds
examples/experimental/custom-projection, which renders COGs in arbitrary planar map projections with no basemap. Polar stereographic is the headline, since Web Mercator can't show polar data at all. Equal Earth and Web Mercator (for comparison) go through the same pipeline.Closes #646
Ref #330
deck.gl merged experimental support for custom projections as
_CustomProjectionViewin visgl/deck.gl#10741 (tracker visgl/deck.gl#10739). It ships with deck.gl v10, and master is already on luma.gl 10 alpha. This example runs on deck.gl 9.4 through a stand-in with the same API. No library code changes.What's in it
src/custom-projection/: a stand-in for_CustomProjectionView, its viewport and its controller, built onOrthographicView.projectionas a proj4 converter,fromCrs,toCrs,fromBounds) and the same{center: [lng, lat], zoom}view state.NORMALIZATION_SCALE), as dopreproject,postUnproject,projectFlatandprojectionSignature.src/projected-cog-layer/:ProjectedCOGLayer, aCOGLayerthat also works in a custom-projection view. In any other view it behaves likeCOGLayer.CustomProjectionTileset2Dselects tiles in the map's CRS: frustum culling in common space, an LOD measured from each tile's drawn area on screen, and domain-aware culling.RasterLayermesh is reprojected straight into map meters and drawn withcoordinateSystem: "cartesian", upstream's convention for preprojected positions. The existing fp64 split keeps it precise.projectTo4326composed with the view's converter), so the layer never needs a proj4 definition of the map CRS.Vector context (coastlines, graticule, domain outline) is projected on the CPU.
Data:
Views can be bookmarked with URL parameters; the README lists some.
Moving to
_CustomProjectionViewin v10The two changes have to land together:
src/custom-projection/. The layers already take the domain through afromBoundsprop, because upstream's viewport doesn't expose it.instanceof GlobeViewportinstead ofviewport.resolution !== undefined. Upstream's viewport setsresolution = 0, which would sendRasterLayerdown its globe-only mesh path.Longer term,
ProjectedCOGLayer's logic could become a third projection mode inRasterTileset2D/RasterTileLayer, soCOGLayer,ZarrLayerandMultiCOGLayerwould all work in a custom-projection view.Limitations
Notes for review
pnpm-workspace.yamlline and thedocs.ymlloop change (first commit) are byte-identical to Kyle/elevation example #647's, so the two merge cleanly in either order. Without thedocs.ymlchange, addingexamples/experimental/breaks the docs deploy.@deck.gl/react.pnpm test. They cover the stand-in, the traversal, and mesh convergence for polar views atRasterLayer's real iteration cap. Typecheck and Biome are clean, and the example builds.🤖 Written by Claude Code