Skip to content

feat: Zarr AEF example - #467

Merged
kylebarron merged 25 commits into
mainfrom
kyle/zarr-aef-mosaic
Apr 24, 2026
Merged

kylebarron merged 25 commits into
mainfrom
kyle/zarr-aef-mosaic

Conversation

@kylebarron

@kylebarron kylebarron commented Apr 24, 2026 •

Copy link
Copy Markdown
Member
image

Change list

The creation of this example also discovered improvements merged separately in #464, #465, #466

Future todo

  • cosine similarity to a picked pixel?

kylebarron and others added 22 commits April 23, 2026 14:16
AlphaEarth Foundations GeoZarr Mosaic example. Uploads 64 bands per tile as
an r8sint Texture2DArray; users pick three bands for an RGB composite and
dequantization happens in-shader. One upstream ZarrLayer change: derive tile
size from the inner sharding codec chunk, not the outer shard.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Verified that [email protected]'s Array.chunks already returns the inner sharding
chunk shape for sharded arrays (hierarchy.js createContext sets chunkShape
from the sharding codec configuration). So the existing
arr.chunks[arr.chunks.length - 1] tile-size derivation is correct for the AEF
store, and the planned upstream change is a no-op.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Vite + React + MapLibre scaffolding for the AlphaEarth Foundations GeoZarr
Mosaic example. No data layer yet — just a dark basemap centered on San
Francisco Bay to confirm the dev server boots.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Static data modules for the example: zarr URL + dequantization constants,
buildSelection() for pinning the year, and a list of preset regions for the
location dropdown.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Combined sample + dequantize + rescale module. Samples three layers of an
r8sint Texture2DArray at user-selected band indices, dequantizes via
(v/127.5)^2 * sign(v) in-shader, linearly rescales each channel to [0, 1],
and discards pixels where any sampled channel is the int8 nodata sentinel
-128.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Slices one year × all 64 bands × tile bounds via zarrita, uploads the raw
int8 data to an r8sint Texture2DArray. Checks chunk shape defensively to
catch selection/metadata misalignments early.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Opens the embeddings array, passes the root group attrs to ZarrLayer as a
metadata override (the store's top-level spatial:* attrs are already GeoZarr
compliant), and renders bands 0/16/32 as R/G/B for 2025 with a [-0.3, 0.3]
rescale. No UI controls yet — state is hardcoded to establish the rendering
path end-to-end.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Location dropdown (flyTo), year slider (re-keys layer → refetch), three band
dropdowns (uniform-only change), and a shared rescale range slider. Band
labels fetched asynchronously from the `band` zarr coord at mount.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The AEF mosaic example relies on zarrita returning the inner sharding
chunk shape via arr.chunks (not the outer 4096x4096 shard). This test
synthesizes a sharded Zarr v3 array and asserts arr.chunks equals the
inner chunk shape, so a future zarrita version that changes this behavior
fails loudly.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The traversal's z=0 loop instantiated every tile in the coarsest level's
matrix upfront, relying on frustum culling downstream to discard the ones
outside the viewport. For traditional OGC pyramids that's fine (z=0 is ~1
tile), but single-level Zarr descriptors can be thousands × thousands of
tiles at their native resolution — the AEF mosaic (4009984 × 1859584 px at
256² tiles) instantiates ~114M RasterTileNodes at startup, effectively
hanging the page.

Cull to the intersection of the dataset extent and the viewport's WGS84
bounds: project the four corners into the source CRS via
`descriptor.projectFrom4326` and consult the root level's existing
crsBoundsToTileRange. Typical viewport → tens of root tiles. If the
viewport and dataset don't overlap, traversal is skipped entirely.

Prototype commit — to be extracted onto its own branch for a standalone
perf: PR once verified end-to-end via the AEF example.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
# Conflicts:
#	packages/deck.gl-raster/src/raster-tileset/raster-tile-traversal.ts
Replace the app-level viewport-zoom gate with the layer's built-in
minZoom / visibleMinZoom pair (new in deck.gl 9.3). Tiles fetched at
zoom ≥ 12 remain visible down to zoom 11, so zooming out by one level
stays smooth instead of snapping to blank.

Adds `visibleMinZoom` / `visibleMaxZoom` to the RasterTileLayerProps
pass-through so any RasterTileLayer subclass (ZarrLayer, COGLayer) can
expose them.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Matches PR #466 (refactor: Don't honor visibleMinZoom / visibleMaxZoom).
Consolidates FETCH_MIN_ZOOM / VISIBLE_MIN_ZOOM into a single MIN_ZOOM
constant and removes the visibleMin/MaxZoom pass-through from
RasterTileLayerProps (the passthrough never landed on main; it was only
ever in the earlier commit on this branch).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Better UX mapping between control type and cost:
- Year → dropdown. Changing the year refetches every visible tile
  (new zarr chunks), so discrete commits are right.
- R / G / B band → sliders. Changing bands is a shader uniform change
  with no network — scrubbing should feel instant, and the wider label
  ("Red band: A17") updates live as you drag.

Rescale range was already a slider; location stays a dropdown.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@github-actions github-actions Bot added the feat label Apr 24, 2026
@kylebarron
kylebarron marked this pull request as ready for review April 24, 2026 16:23
@kylebarron
kylebarron enabled auto-merge (squash) April 24, 2026 16:25
@kylebarron
kylebarron merged commit 186478b into main Apr 24, 2026
4 checks passed
@kylebarron
kylebarron deleted the kyle/zarr-aef-mosaic branch April 24, 2026 16:25
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.

1 participant