Skip to content

feat(deck.gl-zarr)!: open ZarrSource from a store with a path, and inherit a group's GeoZarr metadata - #838

Merged
kylebarron merged 12 commits into
mainfrom
kyle/zarr-source-group-metadata
Nov 6, 2026
Merged

kylebarron merged 12 commits into
mainfrom
kyle/zarr-source-group-metadata

Conversation

@kylebarron

@kylebarron kylebarron commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Note

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

ZarrSource.open now starts from a zarrita store, and path says which array or multiscales group to draw. is checks the data type and narrows the source:

const store = new zarr.FetchStore("https://example.com/data.zarr");
const source = await ZarrSource.open(store, { path: "temperature" });
if (!source.is("float32")) {
  throw new Error("Expected float32");
}
  • path replaces variable. It's the /-separated path to the array or multiscales group to draw. A relative path starts at the input, and an absolute one, such as "/temperature", at the store's root.
  • ZarrSource.open takes a store, as well as an opened group or array, and starts from the store's root. An opened node stays as the escape hatch: for an app that has opened it already, for example to read coordinate or label arrays or to browse the hierarchy, or that needs control over how it was opened. A node is told from a store by having both a store, which zarrita's own open checks for, and a kind. instanceof would fail for a second copy of zarrita.
  • ZarrSource.is(dtype) checks the data type. It checks the levels' data type at run time and narrows the source's type, as zarrita's Array.is does for an array. open no longer takes a data type argument: it returns a general ZarrSource, and checks that every level has the same data type. zarrita doesn't export its DataTypeQuery type, so is takes concrete data types only, not categories like "number".
  • ZarrLayer's source shorthand takes the same inputs, a store included, as COGLayer's takes any input of COGSource.open. The layer draws a store's root, since it can't pass a path, and it can't check the data type of data it opens. The new ZarrInput type names these inputs, like COGInput.
  • The Store type parameter is gone from ZarrSource, ZarrInput, ZarrLayer and ZarrLayerProps: they take any zarr.Readable. ZarrLayer again extends RasterTileLayer with two type parameters, like COGLayer.
  • ZarrSource opens nodes as Zarr v3 first, then v2. zarrita's open tries v2 first on a store it hasn't opened before, which costs a v3 store one or two requests.
  • source.node is the group or array drawn: the multiscales group of a pyramid, or the array of a single level. Its store reaches the dataset's other arrays: zarr.open(zarr.root(source.node.store).resolve("band"), { kind: "array" }).
  • source.arrays is now source.levels: one opened array per resolution level, finest first.

An array inherits the GeoZarr metadata of its group however it's reached: named by path, passed in, or at a store's root. The rules follow the proj and spatial conventions:

  • Only the group the array is directly in. "It does not apply to groups or arrays deeper in the hierarchy." open reuses the input when it's that group, and opens it otherwise. An array at the root of a store has no group, and an array whose group can't be found inherits nothing.
  • Only proj: and spatial: attributes. The group's multiscales describes the group's own levels. Groups never inherit.
  • The array's CRS replaces the group's whole. "An array can override the group's proj convention with its own CRS definition."
  • Each spatial: attribute of the array replaces the group's. Arrays can "override or supplement group-level definitions".
  • geoZarrMetadata replaces all of it, so open reads no group then.

Single-scale data is drawn from its array, named by path, such as aef-mosaic's embeddings, which takes the proj: and spatial: attributes of the group it's in. Drawing a group whose metadata has no multiscales fails with an error that asks for the array's path, since such a group can hold several arrays. Before, it failed with zarrita's Not found: v2 array.

The examples open their stores. aef-mosaic passes path, and reads its band labels through source.node. dynamical-zarr-ecmwf and nldas-icechunk pass path and their geoZarrMetadata, and nldas-icechunk reads missing_value from source.node. These three check their data type with is, and throw an error naming the expected and actual data types. zarr-sentinel2-tci passes its store to the layer.

Migration

This changes ZarrSource.open from 0.10.0-beta.1 and beta.2:

  • Rename the variable option to path.

  • Pass the store, rather than a group you opened:

    // Before
    const group = await zarr.open(store, { kind: "group" });
    const source = await ZarrSource.open(group, { variable: "temperature" });
    
    // After
    const source = await ZarrSource.open(store, { path: "temperature" });

    ZarrLayer's source takes the store as well.

  • Narrow the data type with is, instead of passing it to open, which now returns a general ZarrSource:

    // Before
    const source = await ZarrSource.open<"float32">(group);
    
    // After
    const source = await ZarrSource.open(store);
    if (!source.is("float32")) {
      throw new Error("Expected float32");
    }
  • Drop the Store type argument of ZarrSource, ZarrLayer and ZarrLayerProps.

  • Rename source.arrays to source.levels.

  • An array passed in now inherits its group's proj: and spatial: attributes. That reads the group's metadata, unless you pass geoZarrMetadata.

Tests

  • New tests in zarr-source.test.ts cover the store input, relative and absolute paths, node, is and its narrowing, levels whose data types differ, the v3-first opens and each inheritance rule above. A store that records its reads shows no .zgroup, .zarray or .zattrs reads for a v3 store. Each rule's test fails when its code is mutated.

  • zarr-layer.test.ts opens a store passed as source, and the type tests check that source takes a store.

  • I measured each example's open code in Node, before (on main) and after, against its real data. Both opened the same arrays, with the same tile grid and bounds:

    Example What was counted Before After
    aef-mosaic requests to open, and band labels 4 4
    dynamical-zarr-ecmwf requests to open, and one chunk 4 4
    nldas-icechunk requests to open, and one chunk, after the repo setup 2 2
    zarr-sentinel2-tci store reads, on an in-memory v3 store, since its data is local 6 4

    nldas-icechunk also makes 2 fewer store reads (.zattrs and .zarray), which icechunk answers without a request. On the real data, is holds for each example's data type: int8 for aef-mosaic, float32 for the other two.

  • I loaded the built aef-mosaic, dynamical-zarr-ecmwf and nldas-icechunk examples in a headed Chrome, and each drew its data. The only console warning was luma.gl's Binding sampler not set, which the deployed aef-mosaic shows too. I couldn't load zarr-sentinel2-tci, which reads a local store.

  • pnpm -r --filter='!docs' typecheck, pnpm -r test, Biome, and the four examples' builds pass.

Closes #813

🤖 Written by Claude Code

`ZarrSource.open`'s `variable` can name an array as well as a group. An
array inherits the `proj:` and `spatial:` attributes of the group it's
in: its own CRS replaces the group's, and each of its own `spatial:`
attributes replaces the group's. A group with single-level metadata now
fails with an error that asks for `variable`.

The aef-mosaic example opens its data with `variable` instead of passing
the root's attributes as `geoZarrMetadata`.

Closes #813

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the feat label Nov 4, 2026
kylebarron and others added 4 commits November 4, 2026 17:17
`ZarrSource.open` takes a zarrita store as well as an opened group or
array, and the `variable` option is now `path`: the relative path from
the input to the array or multiscales group to draw.

It opens nodes as Zarr v3 first, then v2, so a v3 store gets no v2
requests. Every array inherits its group's GeoZarr metadata, however
it's reached, unless `geoZarrMetadata` is given. The source keeps the
group or array it drew as `node`.

aef-mosaic opens its store with a path, and reads its band labels from
the source's store.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The `source` shorthand takes anything `ZarrSource.open` does, as
COGLayer's takes any input of `COGSource.open`. The layer draws a
store's root, since it can't pass a `path`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
dynamical-zarr-ecmwf and nldas-icechunk open their stores with a path
and their `geoZarrMetadata`, and nldas-icechunk reads `missing_value`
from the source's node. zarr-sentinel2-tci passes its store to the
layer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Show `ZarrSource.open(store, { path })` and the layer's store shorthand
first, then `node`, and the opened group or array as the escape hatch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kylebarron kylebarron changed the title feat(deck.gl-zarr): inherit a group's GeoZarr metadata in ZarrSource feat(deck.gl-zarr)!: open ZarrSource from a store with a path, and inherit a group's GeoZarr metadata Nov 4, 2026
@kylebarron

Copy link
Copy Markdown
Member Author

Note

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

I revised the PR so that apps mostly deal with ZarrSource rather than zarr.open:

  • 54f3418f: ZarrSource.open(store, { path }). path replaces variable. open takes a store as well as an opened group or array, opens nodes as Zarr v3 before v2, and keeps the group or array it draws as source.node. Every array inherits its group's GeoZarr metadata however it's reached, unless geoZarrMetadata is given.
  • 71843ae1: ZarrLayer's source shorthand takes a store.
  • 36e2db6a: the four Zarr examples open their stores.
  • 8348a4f2: the deck.gl-zarr README leads with the store form, and keeps the opened node as the escape hatch.

A node is told from a store by having both a store and a kind, not by instanceof. The examples make as many requests as before, and the zarr-sentinel2-tci flow makes 2 fewer reads. The description has the counts and the migration notes.

🤖 Written by Claude Code

…p-metadata

# Conflicts:
#	packages/deck.gl-zarr/src/zarr-layer.ts
Comment thread examples/aef-mosaic/src/App.tsx Outdated
// The GeoZarr metadata is on the root group, not on the array
const source = await ZarrSource.open(opened, {
geoZarrMetadata: root.attrs,
const source = await ZarrSource.open<"int8">(root, {

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 assume this int8 is just a type declaration? Like there's no assertion happening? Whereas previously there was an assertion that the type was int8...

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.

Yes, ZarrSource.open<"int8"> was only a type argument, and nothing checked it. Now open returns a general ZarrSource, and the example narrows it with source.is("int8"). That checks the arrays' data type at run time, and the example throws Expected AEF embeddings to be int8, got ... otherwise, as on main. Fixed in c04d8c8f.

🤖 Written by Claude Code

Comment on lines +34 to +37
* [proj](https://github.com/zarr-conventions/geo-proj/blob/5ca5b2f92e5c7245f957d9128b289ee535f0720d/README.md#inheritance-model)
* and
* [spatial](https://github.com/zarr-conventions/spatial/blob/54d81b7ced0376e63ee10f34db31db7d08dcc28d/README.md#can-i-use-spatial-at-the-group-level)
* conventions.

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.

For readability can we put the links at the bottom of the comment and use tags instead of git hashes?

I.e.

[proj]: https://github.com/zarr-conventions/proj/blob/v0.1/README.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.

Note

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

Done in 3464c263. The docstring now says See the [proj] and [spatial] conventions, and defines both links at the end of its description, on the v0.1 tags. proj points at zarr-conventions/proj, the new name of geo-proj, and both keep their anchors. The definitions sit just above @param, as in tile-matrix-set.ts, so they stay in the same Markdown block as the text that uses them.

🤖 Written by Claude Code

*/
export async function fetchBandLabels(
root: zarr.Group<zarr.Readable>,
root: zarr.Location<zarr.Readable>,

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.

oo what is zarr.Location? What is that type def? I hadn't seen that name before

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.

zarr.Location is zarrita's plain { store, path } pair, with no I/O. zarr.root(store) makes one at /, location.resolve(path) makes another, and Group and Array both extend Location. fetchBandLabels only needs a place to resolve band from, not an opened group, so it takes a Location. No code change.

🤖 Written by Claude Code

new zarr.FetchStore(ZARR_URL),
{ path: VARIABLE },
);
const labels = await fetchBandLabels(zarr.root(source.node.store));

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.

Does zarr.root open again?

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.

No. zarr.root(store) is new Location(store), and reads nothing. The root's zarr.json is read once, by ZarrSource.open, for the metadata embeddings inherits, and fetchBandLabels opens only band. Against the real store, the example reads embeddings/zarr.json, zarr.json, band/zarr.json and band/c/0: 4 requests, as on main. No code change.

🤖 Written by Claude Code

Comment thread examples/aef-mosaic/src/App.tsx Outdated
geoZarrMetadata: root.attrs,
});
const labels = await fetchBandLabels(root);
const source = await ZarrSource.open<"int8">(

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.

Eh, I still wish we could have a runtime dtype assertion. But I don't want it to be a param we pass in.

What if we defined the same .is method just like the upstream Zarr object? So we have ZarrSource as something entirely general, but then you use the is type guard to narrow it?

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 c04d8c8f. ZarrSource.is(dtype) checks the arrays' data type at run time and narrows the source, as zarrita's Array.is does for an array. open no longer takes a type argument: it returns a general ZarrSource, and checks that every level has the same data type. zarrita doesn't export its DataTypeQuery type, so is takes concrete data types only, not categories like "number". aef-mosaic, dynamical-zarr-ecmwf and nldas-icechunk check theirs with is again.

🤖 Written by Claude Code

setSource(source);
// Default to the latest available forecast run.
setInitTimeIdx(opened.shape[0]! - 1);
setInitTimeIdx(source.arrays[0]!.shape[0]! - 1);

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.

What is source.arrays? And why is that an Array? Shouldn't the arrays be named? Or what's the shape of source.arrays?

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.

It's one zarrita array per resolution level, finest first. arrays[0] is full resolution, and for single-resolution data like ECMWF it's the only entry. It's an ordered array rather than named because the levels are ordered by resolution, and the tile grid's zoom indexes into it. The name could be clearer, such as levels. Do you want it renamed? No code change for now.

🤖 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.

Renamed it to levels in dd4c5cf2, since that says what it holds: one opened array per resolution level, finest first. The examples and tests use source.levels, and the description's Migration section lists the rename.

eaee14e5 also adds source.is(...) to the README's ZarrSource.open example, and links the spatial convention in validation.ts by its v0.1 tag.

🤖 Written by Claude Code

* the array's name in the NLDAS-3 store, so the literal path can't change.
*/
export const SURFACE_TEMP_PATH = "/Tair";
export const SURFACE_TEMP_PATH = "Tair";

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.

Hmm, is this breaking? Or like, will upstream zarrita.js work without the initial /? Or is this something that we're working around?

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.

Not breaking: zarrita's Location.resolve uses URL resolution, so "/Tair" and "Tair" both resolve to /Tair from the root. I had changed it only because path was documented as relative. In 7665250f it's back to "/Tair", and path's docs say an absolute path starts at the store's root, with a test.

🤖 Written by Claude Code

: null;
const zarrLayer = new ZarrLayer<SentinelTileData>({
id: "zarr-layer",
source: STORE,

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.

here we're passing STORE, but that's a FetchStore; previously we passed in a node, which was a zarr.Group?

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.

Yes, on purpose. Since 71843ae1, ZarrLayer's source shorthand takes anything ZarrSource.open does, a store included. TCI.zarr's root is the multiscales group, so the layer opens that same group from the store. No code change.

🤖 Written by Claude Code

Comment thread packages/deck.gl-zarr/src/zarr-layer.ts Outdated
Comment on lines +148 to +150
// The defaults can't split a generic `Store` out of `source`
ZarrSource<Dtype, Store>,
ZarrInput<Dtype, Store>

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.

Doesn't the COGLayer use some type operations to provide defaults here? It's pretty verbose to have 4 type params

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.

Yes. The bare Store type parameter in source's union kept RasterTileLayer's Extract/Exclude defaults from splitting it. With Store gone in f15bcbb5, ZarrLayer extends RasterTileLayer<DataT, ZarrLayerProps<DataT, Dtype>> with two parameters, like COGLayer, and the defaults resolve.

🤖 Written by Claude Code

export type ZarrInput<
Dtype extends zarr.DataType = zarr.DataType,
Store extends zarr.Readable = zarr.Readable,
> = Store | zarr.Group<Store> | zarr.Array<Dtype, Store>;

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.

Should our Store be parameterized?

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.

No, it's removed in f15bcbb5. It only typed the .store of nodes, and no example used it. An app that needs its concrete store type built the store, so it already has it.

🤖 Written by Claude Code

kylebarron and others added 6 commits November 4, 2026 18:12
`ZarrSource`, `ZarrInput`, `ZarrLayer` and `ZarrLayerProps` take any
`zarr.Readable`. The bare `Store` in `source`'s union kept
`RasterTileLayer`'s defaults from splitting it, so `ZarrLayer` extends
`RasterTileLayer` with two type parameters again, like `COGLayer`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`ZarrSource.is(dtype)` checks the arrays' data type at run time and
narrows the source's type, as zarrita's `Array.is` does for an array.
`ZarrSource.open` no longer takes a data type argument: it returns a
general `ZarrSource`, and checks that every level has the same data
type. aef-mosaic, dynamical-zarr-ecmwf and nldas-icechunk check their
data types with `is` again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use reference-style links at the end of the `ZarrSource.open` docstring,
pointing at the conventions' `v0.1` tags. `geo-proj` is now
`zarr-conventions/proj`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`path` is relative to the input, and an absolute path starts at the
store's root, as zarrita's `Location.resolve` does. nldas-icechunk
keeps its `"/Tair"`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
It holds one opened array per resolution level, finest first, which
`levels` says and `arrays` didn't.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…atial convention by tag

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron added a commit that referenced this pull request Nov 5, 2026
> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

Bumps `version` to `0.10.0-beta.3` in the root `package.json` and in
every `packages/*/package.json`. The publish workflow publishes it under
the `beta` dist-tag, so `latest` stays on 0.9.0.

`CHANGELOG.md` gets a `v0.10.0-beta.3` section with GitHub's generated
notes for the 17 PRs merged since v0.10.0-beta.2.

## Breaking change

- #843: `MosaicLayer` no longer takes `maxCacheByteSize`. To bound an
item's memory by bytes, set `maxCacheByteSize` on the layer that
`renderSource` returns.

## Behavior changes

- #839: a `MosaicLayer` item out of view keeps its opened source in the
cache but drops its layers, which frees their textures.
- #785: `parseGeoZarrMetadata` takes Y from the first entry of
`spatial:dimensions` and X from the second, whatever their names, as
v0.1 of the spatial convention says. Lists that aren't two entries long
are rejected.
- #841: `RasterTileset2D.getParentIndex` picks the parent tile that
contains the child's centre.

## New APIs

- #835: `parseVRT` in `@developmentseed/deck.gl-geotiff`, and `fromGDAL`
in `@developmentseed/affine`.
- #789: `renderSource` gets the props that `MosaicLayer` passes to its
sublayers.

## Not included

#838 (`ZarrSource` opens from a store with a `path`) and #837
(`DEFAULT_RANGE_READER` moves to `@developmentseed/deck.gl-raster`) are
still open. Both are breaking.

🤖 Written by [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
@kylebarron

kylebarron commented Nov 6, 2026 •

Copy link
Copy Markdown
Member Author

ZarrSource.open now starts from a zarrita store, and path says which array or multiscales group to draw.

So what if you don't pass a path? It opens at root?

is checks the data type and narrows the source:

👍

  • path replaces variable. It's the /-separated path to the array or multiscales group to draw. A relative path starts at the input, and an absolute one, such as "/temperature", at the store's root.

I think path is a better zarr terminology; would you agree?

  • source.arrays is now source.levels: one opened array per resolution level, finest first.

Hmm, still not 100% sure on what the naming should be here.

ZarrSource.open on a group whose metadata has no multiscales fails with an error that asks for path.

We should support single-scale GeoZarr datasets...

// Number of init_time values in the dataset (= first dim of the array),
// known once the zarr array is opened.
const initTimeCount = source ? source.arrays[0]!.shape[0]! : 0;
const initTimeCount = source ? source.levels[0]!.shape[0]! : 0;

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.

So source.levels is specifically the multiscale levels? Or is it more generic than that? If it's multiscale specifically, perhaps it should be source.scales?

But I don't want to create a new term if there's already a right term in the zarr community

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.

It's the multiscales levels: one opened array per entry of the group's multiscales layout. Single-scale data, an array named by path, has one level.

The multiscales convention calls each of those entries a "resolution level", or "level":

  • layout is "an array of objects representing each resolution level", and "each object in the layout array represents a single resolution level".
  • derived_from and transform describe relations "between resolution levels", and resampling_method applies "across all levels".

"Scale" means something else there: each entry's transform.scale is its scale factor per axis, relative to the level it's derived from. So source.scales would read as those factors. I'd keep levels, the convention's own word.

I also found that the spec doesn't fix the order of layout. Its DEM example lists a 10 m upsampled level last, after 270 m. Our parseGeoZarrMetadata keeps the layout's order and assumes it's finest first, and geoZarrToDescriptor reverses it to get coarsest first. So a layout listed in another order gets a tile grid with its levels out of order. That's on main already, not new here. I'd fix it in its own PR, by sorting the levels by pixel size, so that levels is finest first for any layout.

🤖 Written by Claude Code

@kylebarron

Copy link
Copy Markdown
Member Author

Note

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

So what if you don't pass a path? It opens at root?

Yes, for a store. Without path, open draws the input itself: a store's root, or the group or array passed in. That works when the root is a multiscales group, as in zarr-sentinel2-tci, or an array.

I think path is a better zarr terminology; would you agree?

Yes. Zarr names a node in a hierarchy by its path: zarrita's Location has a path and resolve(path), and zarr-python's open, open_array and open_group take path=. variable is xarray's word for an array in a Dataset, and doesn't fit a multiscales group, which path can name too.

Hmm, still not 100% sure on what the naming should be here.

The candidates I see:

Name For Against
levels (now) Same word and order as GeoZarrMetadata.levels, which follows the multiscales layout: finest first RasterTilesetDescriptor.levels is coarsest first, so one word has two orders in the codebase
arrays (beta.2) Says what they are Doesn't say there's one per level, or which comes first
overviews GeoTIFF's word GeoTIFF's overviews leave out the full-resolution image; these include it

I'd keep levels. It matches the GeoZarr metadata the source is read from. The descriptor's levels are indexed by tile zoom, inside the tileset and layer code. Every use of source.levels in the examples is levels[0], to read the data type or the length of a non-spatial dimension.

We should support single-scale GeoZarr datasets...

They are supported: name the array with path. aef-mosaic draws one. Its root group has the proj: and spatial: attributes and no multiscales, and its embeddings array has none of its own. ZarrSource.open(store, { path: "embeddings" }) gives the array its group's attributes, by the inheritance rules above.

What fails is drawing such a group without path. A single-scale group can hold several arrays, such as data variables and coordinates, and the layer draws one of them. My sentence in the description made this sound broader than it is, so I'll reword it.

open could instead pick the group's only array that has both spatial dimensions. But a store can list a group's arrays only when it has consolidated metadata, and AEF's store has none, so AEF would still need path. I'd keep asking for path.

🤖 Written by Claude Code

export type ZarrLayerProps<
DataT extends MinimalTileData = MinimalTileData,
Dtype extends zarr.DataType = zarr.DataType,
Store extends zarr.Readable = zarr.Readable,

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.

This is gone because it's now a type parameter on the ZarrSource, right?

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 see it's not a type parameter now on ZarrSource; should it be?

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.

Right, it's gone from both. f15bcbb5 dropped it from ZarrSource, ZarrInput, ZarrLayer and ZarrLayerProps, after your questions on whether Store should be parameterized and on the four type parameters.

I don't think it should come back:

  • It only typed the .store of source.node and of each level's array. Nothing in ZarrSource or ZarrLayer needs more than zarr.Readable, and no example used the narrower type.
  • An app that needs its store's own type, for example to call contents() on a store from withConsolidatedMetadata, built that store, so it already has it.
  • As a bare type parameter in source's union, it kept RasterTileLayer's defaults from splitting the union, so ZarrLayer needed four type parameters. Without it, ZarrLayer has two, like COGLayer. COGSource has no type parameters either.

🤖 Written by Claude Code

* Called with the source the layer opened, when `source` isn't an opened
* {@link ZarrSource} already.
*/
onSourceLoad?: (source: ZarrSource<Dtype, Store>) => void;

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.

Oh I see, it was but we took it out?

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.

Yes, in f15bcbb5. My reply in the thread above says why I'd leave it out.

🤖 Written by Claude Code

});
```

`source.is(dtype)` checks the data type at run time and narrows the source's type to it, as zarrita's `Array.is` does for an array.

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.

does this work both for groups (multiscale groups?) as well as single arrays?

Does ZarrSource reject groups that are not multiscale groups?

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.

does this work both for groups (multiscale groups?) as well as single arrays?

Yes. is checks the first level's array (L133-L135), and open already rejected the data if the levels' data types differ (L217). So the check holds for every level: the levels of a multiscales group, or the single level of an array.

Does ZarrSource reject groups that are not multiscale groups?

Yes. A group whose GeoZarr metadata has no multiscales is rejected, with an error that asks for the path of the array to draw (L182-L188), and a group with no GeoZarr metadata fails to parse. So every ZarrSource has at least one level, and is always has an array to check.

🤖 Written by Claude Code

for (const arr of rest) {
if (arr.dtype !== first!.dtype) {
throw new Error(
"ZarrSource requires every level to have the same data_type: " +

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 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 ddbd1fb into main Nov 6, 2026
5 checks passed
@kylebarron
kylebarron deleted the kyle/zarr-source-group-metadata branch November 6, 2026 15:44
kylebarron added a commit that referenced this pull request Nov 6, 2026
… path

#838 renamed `source.arrays` to `source.levels`, and opens a store with a
path. This follows dynamical-zarr-ecmwf.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron added a commit that referenced this pull request Nov 6, 2026
> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

Bumps `version` to `0.10.0-beta.4` in the root `package.json` and in
every `packages/*/package.json`. The publish workflow publishes it under
the `beta` dist-tag, so `latest` doesn't change.

`CHANGELOG.md` gets a `v0.10.0-beta.4` section with GitHub's generated
notes for the 6 PRs merged since v0.10.0-beta.3.

## Breaking changes

- #837: `DEFAULT_RANGE_READER` moves from
`@developmentseed/deck.gl-geotiff` to `@developmentseed/deck.gl-raster`.
- #838: `ZarrSource.open` takes the store and a `path` option, instead
of a group you opened and `variable`. ZarrLayer's `source` takes a store
too.
- `open` returns a general `ZarrSource`. Narrow its data type with
`source.is("float32")`.
  - `source.arrays` is renamed to `source.levels`.
- `ZarrSource`, `ZarrLayer` and `ZarrLayerProps` lose their `Store` type
argument.

## Behavior changes

- #838: an array passed in inherits its parent group's `proj:` and
`spatial:` attributes, unless you pass `geoZarrMetadata`.
- #851: `parseGeoZarrMetadata` orders a multiscales group's levels
finest first by pixel size, whatever order its `layout` lists them in.
- #848: a change to `MosaicLayer`'s `updateTriggers.getSource` (or
`all`) unloads every item's source and opens the sources in view again.
The old items stop drawing at once.

## New APIs

- #792: `read({ window, pool, signal })` on `GeoTIFF` and `Overview`,
with the `Window` type and the `WindowError` class.
- #838: `ZarrSource.is(dtype)` and `source.node`.

## Not included

The fix for #826 (the range reader sends a read again when it arrives as
the stream holding its bytes finishes) isn't written yet.

🤖 Written by [Claude Code](https://claude.com/claude-code)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ZarrSource can't open an array whose GeoZarr metadata is on its parent group

1 participant