Skip to content

fix(geozarr): accept arbitrary spatial:dimensions names - #785

Open
kylebarron wants to merge 1 commit into
mainfrom
kyle/geozarr-positional-dims
Open

kylebarron wants to merge 1 commit into
mainfrom
kyle/geozarr-positional-dims

Conversation

@kylebarron

Copy link
Copy Markdown
Member

Note

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

parseGeoZarrMetadata found the Y and X axes only by the labels y/latitude/lat and x/longitude/lon, and threw for any other names. The spatial convention leaves the names in spatial:dimensions free and identifies the axes by position (row-major [y, x] or [z, y, x]), so ZarrLayer couldn't load spec-compliant data such as ["northing", "easting"]. The labels still decide when both a Y and an X label are present, so every dataset that parses today gets the same axes. Otherwise Y and X are now the last two entries.

Changes

  • parseGeoZarrMetadata uses the last two spatial:dimensions entries as Y and X, instead of throwing, when the names aren't recognized. The schema already requires at least 2 entries.
  • Updated its docstring and inline comment to describe the rule.
  • ZarrLayer needs no change: it matches the spatial dims against each array's dimension_names by name.

Tests

  • New packages/geozarr/tests/parse.test.ts: ["northing", "easting"] and ["depth", "northing", "easting"] resolve Y and X by position, ["lon", "lat"] still resolves by label, and a 1-entry list is rejected.
  • 2 of the 4 new tests (the positional cases) fail against main. The other two guard existing behavior.

Notes

  • v0.1 of the spatial convention, newer than the vendored submodule, allows exactly two entries ordered Y then X and tells readers to rely on that order rather than parse the names. Under it, ["lon", "lat"] would mean Y = lon. Labels keep precedence here so data that parses today keeps the same axes.

Closes #451

🤖 Written by Claude Code

The spatial convention leaves the names in `spatial:dimensions` free and
lists them in row-major order (`[y, x]` or `[z, y, x]`), so Y and X are
the last two entries. `parseGeoZarrMetadata` only recognized the labels
"y"/"latitude"/"lat" and "x"/"longitude"/"lon" and threw for any other
names, such as `["northing", "easting"]`, so ZarrLayer could not load
spec-compliant data that used them.

Keep the label match when both a Y and an X label are present, so every
dataset that parses today gets the same axes, including ones that list
the labels in a non-spec order such as `["lon", "lat"]`. Otherwise take Y
and X from the last two entries. The schema already requires at least
two entries, so the positional indices are always valid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the fix label Oct 23, 2026

This branch has not been deployed

No deployments
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.

geozarr: Double check correct implementation of spatial:dimensions

1 participant