Repository navigation
feat(deck.gl-zarr)!: open GeoZarr data with ZarrSource - #812
Conversation
`ZarrSource.open(node, options)` opens GeoZarr data from a zarrita group or array. It reads the GeoZarr metadata from the node's attributes, or from `geoZarrMetadata`, opens the array of each level, and resolves the CRS. It then builds the tile grid and the WGS84 bounds of the finest level. The source holds `arrays` (finest first), `dimensionNames`, `spatialDims` and `projection`, plus the tile grid and bounds from `RasterSource`. It doesn't keep the parsed GeoZarr metadata. It checks what ZarrLayer's load checks today, except `selection`, which stays on the layer. The tests' GeoZarr store moves to `tests/helpers.ts`, with groups for the failure cases. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ayer's source ZarrLayer's `source` is an opened `ZarrSource`, or a zarrita group or array that the layer opens with `ZarrSource.open`'s defaults. Like COGLayer, it lets RasterTileLayer handle the source and only says how to open input. `onSourceLoad` gets the source it opened. `node`, `variable`, `metadata` and `epsgResolver` are removed. The last three are `ZarrSource.open` options, with `metadata` renamed `geoZarrMetadata`. `selection` stays on the layer. It's checked against the source whenever either changes, including when a source opened from input arrives. A selection that doesn't fit goes to `onError`, and the layer draws nothing until the selection is fixed. Changing the selection never opens the source again. Selections are compared by value, so an inline literal isn't checked or reported again on every render. Edge tiles are clipped with each array's shape, so the layer no longer needs the parsed GeoZarr metadata. The `window.*` debug lines are gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- **Examples:**
- aef-mosaic, dynamical-zarr-ecmwf and nldas-icechunk open a
`ZarrSource` with `geoZarrMetadata` in the effect that already opens
their array.
- nldas-icechunk's store module returns the source, as `SurfaceTemp`.
- zarr-sentinel2-tci passes its group as `source`.
- **README:** deck.gl-zarr's Quick Start passes a group as `source`, and
shows `ZarrSource.open` for the options.
- **Spec:**
- Question 9 is decided: the option is `geoZarrMetadata`, and the source
doesn't keep the parsed metadata.
- Decisions 21 and 23 and the stage 4b entry describe what was built.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…source
ZarrLayer compared `selection` with the old props to decide whether to
check it again. A selection that changed while no source was drawn, such
as while new input opened, was never checked. If the old source came
back, the layer drew the old selection. It now compares the source and
the selection with the pair it last checked, kept in state with whether
the selection fits.
Also from the final review:
- **Tests:**
- A test calls the tile callback. It checks the level, the clipping of
an edge tile, and the selection in the slice spec, using a test group
with a `time` dimension.
- Another test checks that a global grid centered on the poles keeps its
bounds within -90° to 90°.
- The node registration test now says the bounds move, which is what it
shows, and checks `east` too.
- **Types:** `ZarrSource`'s `arrays` and `dimensionNames` are readonly,
since layers share the source.
- **Docs:**
- `selection` says that loaded tiles keep the data of the selection they
were fetched with.
- `open` lists when it rejects, above its parameter.
- The spec says `node` becomes `open`'s first argument, not an option.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
9aade2d to
3142e26
Compare
| /** The opened temperature data plus the fill sentinel read from its attrs. */ | ||
| export interface SurfaceTemp { | ||
| /** The near-surface air temperature, for a `ZarrLayer` to draw. */ | ||
| source: ZarrSource<zarr.Readable, "float32">; |
There was a problem hiding this comment.
I'm not sure it's a good idea for our ZarrSource to have the exact same type parameters as zarr.Array, but switched. If anything we should explicitly follow the same ordering as zarrita.js, right?
There was a problem hiding this comment.
Note
This comment was written by Claude (Claude Code), not by @kylebarron.
Yes. In 6639a88 it's ZarrSource<Dtype, Store>, in the same order as zarrita's zarr.Array<Dtype, Store>. The common case is now just ZarrSource<"float32">, with the store left at its default.
ZarrLayer and ZarrLayerProps had the same switched order, <Store, Dtype, DataT>, from before this PR. I reordered them too, to ZarrLayer<"int8", zarr.Readable, AefTileData>, because:
- this PR already breaks ZarrLayer;
- a layer takes a
ZarrSource, so the two types appear together.
That part is easy to undo if you'd rather keep ZarrLayer's order.
🤖 Written by Claude Code
There was a problem hiding this comment.
Note
This comment was written by Claude (Claude Code), not by @kylebarron.
Follow-up, after your note that layers take DataT first like other deck.gl layers. In b279a15:
- ZarrLayer:
ZarrLayer<DataT, Dtype, Store>, andZarrLayerPropsthe same way.DataTcomes first as inTileLayer<DataT, …>andCOGLayer<DataT>, then zarrita's order. The examples shorten toZarrLayer<AefTileData, "int8">. - ZarrSource: stays
ZarrSource<Dtype, Store>.
On main, ZarrLayer had DataT last (<Store, Dtype, DataT>), so this changes its order too. The PR description's migration section shows the before and after.
🤖 Written by Claude Code
zarrita's `zarr.Array<Dtype, Store>` takes the data type first. Our `ZarrSource`, `ZarrLayer` and `ZarrLayerProps` took the store first, so they now take `Dtype` first too. That also shortens the common case to `ZarrSource<"float32">`, with the store left at its default. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Like deck.gl's `TileLayer<DataT, ...>`, `RasterTileLayer<DataT, ...>` and `COGLayer<DataT>`, ZarrLayer and ZarrLayerProps take `DataT` first, then zarrita's `Dtype` and `Store`. The examples shorten to `ZarrLayer<AefTileData, "int8">`, with the store left at its default. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| null, | ||
| ); | ||
| const [rootAttrs, setRootAttrs] = useState<unknown>(null); | ||
| const [source, setSource] = useState<ZarrSource<"int8"> | null>(null); |
There was a problem hiding this comment.
👍
I like that the simplest type parameteriziation of source is just ZarrSource<Dtype>
| `Expected AEF embeddings to be int8, got ${opened.dtype}`, | ||
| ); | ||
| } | ||
| // The GeoZarr metadata is on the root group, not on the array |
There was a problem hiding this comment.
todo: we should probably somehow manage this ourselves... perhaps ZarrSource should support traversing child nodes? Let's make an issue about this
There was a problem hiding this comment.
Note
This reply was written by Claude (Claude Code), not by @kylebarron.
Filed as #813. It proposes that variable can name an array as well as a group. The conventions apply a group's proj: and spatial: attributes to the arrays directly inside it. So open would read them from the group, and this example could call ZarrSource.open(root, { variable: "embeddings" }).
The issue also lists four open questions. One is how the example would still check that the data is int8.
🤖 Written by Claude Code
| DataT extends MinimalTileData = MinimalTileData, | ||
| Dtype extends zarr.DataType = zarr.DataType, | ||
| Store extends zarr.Readable = zarr.Readable, |
There was a problem hiding this comment.
DataT, Dtype, Store ordering matches COGLayer, right?
There was a problem hiding this comment.
Note
This reply was written by Claude (Claude Code), not by @kylebarron.
Yes, for the part they share. COGLayer takes only DataT (COGLayer<DataT = TextureDataT>), so DataT comes first in both, as in RasterTileLayer<DataT, ...> and deck.gl's TileLayer<DataT, ...>. In b279a15, ZarrLayer's Dtype and Store follow it, in zarrita's order. COGLayer has nothing like them.
🤖 Written by Claude Code
> [!NOTE] > This PR was written by Claude (Claude Code), not by @kylebarron. Bumps `version` to `0.10.0-beta.1` in the root `package.json` and in every `packages/*/package.json`, ready for the first 0.10 beta. The publish workflow sees `beta` in the version and publishes to npm under the `beta` dist-tag, so `latest` stays on 0.9.0. `CHANGELOG.md` gets a `v0.10.0-beta.1` section listing the 19 PRs merged since v0.9.0. ## Publish `@developmentseed/range-reader` by hand before tagging `@developmentseed/range-reader` (#806) isn't on npm yet, and `@developmentseed/geotiff` and `@developmentseed/deck.gl-geotiff` depend on it. The publish workflow can't create it: it publishes only through trusted publishing (OIDC), and npm can add a trusted publisher only to a package that [already exists](https://docs.npmjs.com/cli/v11/commands/npm-trust). Pushing the tag first would fail at `range-reader`. `pnpm publish --recursive` stops at the first failure, so packages published before it in the run would be out, and the rest, including `geotiff` and `deck.gl-geotiff`, would not. Once this is merged, from an up-to-date `main`: 1. Publish it once, as a public package under the `beta` tag. Its `prepublishOnly` script builds it first. ```sh cd packages/range-reader pnpm publish --tag beta --access public --no-git-checks ``` 2. Give it the same trusted publisher as the other packages (workflow `release.yml`, environment `release`), in its settings on npmjs.com or with: ```sh npm trust github @developmentseed/range-reader --file release.yml --repo developmentseed/deck.gl-raster --env release --allow-publish ``` 3. Tag the merge commit `v0.10.0-beta.1` and push the tag. The workflow skips `range-reader`, since that version is already on npm, and publishes the other ten packages. ## Breaking changes - #799: `COGLayer` takes a single `source`: an opened `COGSource`, or any input of `COGSource.open`. `geotiff` becomes `source`, `onGeoTIFFLoad` becomes `onSourceLoad`, and `epsgResolver` and `concurrencyLimiter` move to `COGSource.open`. - #801: `MultiCOGLayer` does the same with `MultiCOGSource`. `sources: { red: { url } }` becomes `source: { red: url }`, `MultiCOGSourceConfig` is removed, and files that don't share a CRS and an extent are rejected. - #804: `MosaicLayer`'s `sources` becomes deck.gl's `data`, and `MosaicSource` becomes `MosaicItem`. The callbacks get the item's opened source as `source`, and `onViewportLoad`'s entries are `{ item, source }`. - #821: `renderSource` gets only `{ source }`, without `signal`. - #812: `ZarrLayer` takes a `ZarrSource`, or a zarrita group or array, as `source`. `node`, `variable`, `metadata` and `epsgResolver` are removed (`metadata` becomes `ZarrSource.open`'s `geoZarrMetadata`), and the type parameters are now `ZarrLayer<DataT, Dtype, Store>`. - #807: `GeoTIFF.fromUrl` no longer takes `chunkSize` or `cacheSize`. They're `RangeReader` options now (`minMetadataReadBytes`, `cache.metadataBytes`). Two behavior changes aren't marked breaking: - #809: COG tile reads are coalesced by default, and `COGLayer` and `MultiCOGLayer` default to `maxRequests: 256` and `debounceTime: 50`. - #818: changing `updateTriggers.getTileData`, or ZarrLayer's `selection`, fetches tiles again, and the old tiles are removed at once. 🤖 Written by [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
Re-applies the change on top of ZarrSource (#812). ZarrSource.open finds the y and x dims (from spatial:dimensions by position, #785) in the arrays' dimension_names with findSpatialDimIndices, and sizes each level's tiles from the chunk sizes at those positions. ZarrLayer's tile callback reads the tile and array sizes at the same positions. The old layer test file is folded into the ZarrSource and ZarrLayer test files, with a shared in-memory array helper. The "rejects arrays with x before y" ZarrSource test and its fixture group are gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Port zarr-globe to the ZarrLayer API from #812, as dynamical-zarr-ecmwf was ported there: open the array with `ZarrSource.open` and the GeoZarr attrs, pass the source as `source`, and use the `ZarrLayer<DataT, Dtype>` type parameter order. Drop `initTimeIdx` from the layer id, since changing `selection` now fetches tiles again (#818). Match dynamical-zarr-ecmwf's dependency versions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Note
This PR was written by Claude (Claude Code), not by @kylebarron.
Stage 4b of the Sources design, part 2 of 2 (
dev-docs/specs/2026-10-22-sources-design.md, decisions 21 to 23). It builds on #811, which moved the projection helpers into@developmentseed/proj.ZarrSource.openopens GeoZarr data once, andZarrLayerdraws it:ZarrSource.open(node, options)takes a zarrita group or array. It does four things:geoZarrMetadata;Its options are
variable,geoZarrMetadata,epsgResolverandsignal.The source holds:
arrays, one per level, finest first;dimensionNamesandspatialDims;projection;tilesetDescriptorandgeographicBounds. Bounds are new for Zarr.It doesn't keep the parsed GeoZarr metadata, since nothing outside
openneeds it (question 9).ZarrLayer's
sourcetakes aZarrSource, or a group or array for the layer to open with the defaults.onSourceLoadgets the source the layer opened. As in COGLayer, RasterTileLayer handles the rest.selectionstays on the layer (decision 22). The layer checks it against the source whenever either differs from the pair it last checked. That includes a source opened from input arriving, and a selection that changed while no source was drawn.onErroras "Can't draw the selection in ZarrLayer: ...", and the layer draws nothing until the selection is fixed. Before, an invalid selection failed the whole load, as "Metadata loading failed in ZarrLayer: ...".selectiondocs now say so; the old docs recommendedupdateTriggers, which doesn't fetch again.Edge tiles are clipped to each array's own shape, rather than to the GeoZarr metadata's.
Cleanup: the
window.*debug lines are gone.Readonly:
arraysanddimensionNamesare readonly, since layers share a source.Migration
node,variable,metadataandepsgResolverare removed from ZarrLayer.metadatabecomes thegeoZarrMetadataoption ofZarrSource.open.TypeScript rejects the removed props. JavaScript ignores them, and without a
sourcethe layer draws nothing.The type parameters are reordered:
ZarrLayer<Store, Dtype, DataT>becomesZarrLayer<DataT, Dtype, Store>, andZarrLayerPropschanges the same way. The tile data type comes first, as in deck.gl'sTileLayer<DataT>andCOGLayer<DataT>, and then zarrita's order, as inzarr.Array<Dtype, Store>.ZarrSource<Dtype, Store>.Examples and docs
ZarrSource: aef-mosaic, dynamical-zarr-ecmwf and nldas-icechunk passgeoZarrMetadata, in the effect that already opens their array. In nldas-icechunk, the store module returns the source.source.Tests
ZarrSource: 12 tests against an in-memory GeoZarr store. They cover:variable,geoZarrMetadata, the dimension names and the tile grid;ZarrSource.open.isLoadedtests and the error-routing test now usesource.state.sourceis exactlyZarrSource, andZarrSource<"int8">for an int8 layer.onSourceLoadgets aZarrSource.source.zarr.json.🤖 Written by Claude Code