Skip to main content

zarr-cm-tree

GeoZarr convention attribute builders — an opinionated bridge between pyproj and zarr-cm.

It produces the plain attribute dicts that make up the attributes block of a Zarr v3 group or array for the GeoZarr conventions proj:, spatial: and multiscales, plus an interim dggs: placeholder.

uv add zarr-cm-tree

Scope

zarr_cm owns the conventions themselves: schemas, validation, revisions, and the zarr_conventions registry entries. This package adds only what it deliberately does not:

  • A pyproj bridge. GeoZarrProj holds a canonical pyproj.CRS and decides how to serialise it — authority code when one exists, WKT2 otherwise — and hands rioxarray a matching CRS string via rio_input().
  • Domain defaults for gridded data. GeoZarrSpatial defaults to ("y", "x") dims and "pixel" registration, and infers transform_type="affine" when a transform is given (transform is optional: omit it for dims-only attrs).
  • Layout rules the schema does not encode, e.g. derived_from requires a transform.
  • geozarr_attrs, which emits several conventions at once together with a matching zarr_conventions registry array, so the registry always describes exactly the conventions present.

Everything returned is a plain dict, never a model, so it merges straight into xarray.Dataset.attrs.

Usage

import zarr_cm_tree as gz

crs = gz.GeoZarrProj.from_user_input("EPSG:27704")  # Equi7Grid EU
spatial = gz.GeoZarrSpatial(
    transform=(10.0, 0.0, 5400000.0, 0.0, -10.0, 2700000.0),
    shape=(10000, 10000),
)

attrs = gz.geozarr_attrs(crs=crs, spatial=spatial)
# {"proj:code": "EPSG:27704", "spatial:transform": [...], "zarr_conventions": [...]}

group.attrs.update(attrs)  # or ds.attrs.update(attrs)

Add a pyramid by passing the layout, one entry per level:

attrs = gz.geozarr_attrs(
    crs=crs,
    multiscales=[
        {"asset": "0"},
        {"asset": "1", "derived_from": "0", "transform": {"scale": [2.0, 2.0]}},
    ],
)

The individual builders (build_proj_attrs, build_spatial_attrs, build_multiscales_attrs, build_zarr_conventions, merge_attrs) are public too, for callers that want to assemble attrs themselves. build_zarr_conventions accepts the legacy "geo-proj" spelling as an alias for "proj", since zarr_cm.ConventionName still carries it and so do stores written before the upstream rename.

Convention revisions

Each convention in zarr_cm ships at one or more numbered revisions. A revision fixes the convention's JSON Schema: which attribute keys are legal, how strictly they are validated, and the schema_url written into the store's zarr_conventions array.

This package writes at whatever revision the installed zarr_cm declares latest, rather than pinning one — a pin nobody updates goes stale, and every store records the revision that wrote it in its own schema_url, so drift stays auditable after the fact. Reading is unaffected either way: zarr_cm.<convention>.detect() sniffs the revision from the store.

current_revisions() reports what is in use:

Convention Current Notes
proj: r3 r2 restricted proj:code to ^[A-Z]+:[0-9]+$, so OGC:CRS84 was invalid
spatial: r3 same keys as r2, looser validation
multiscales r2 the only revision published so far

tests/test_conventions.py asserts these, so a zarr_cm upgrade that ships a new revision surfaces as one failing test rather than silently changing what gets written. When it fails: read what changed, confirm the new attributes are what you want, update EXPECTED_REVISIONS. Stricter validation would fail loudly at ingest anyway; the test is there for the revisions that change quietly.

Known issues

  • Writing a CRS onto a group with no y/x spatial dims (e.g. HEALPix) produces a bogus identity GeoTransform. Carried over from cube-factory (ZarrGroup.to_dataset in _core.py); the fix belongs wherever the rioxarray-facing write path ends up living.

Development

uv sync --all-groups
just test        # pytest
just check       # ruff lint + format + ty

Metadata

Release files for zarr-cm-tree 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zarr-cm-tree 0.2.0
File Size Uploaded Provenance Actions
zarr_cm_tree-0.2.0.tar.gz 10.5 kB With provenance Details for zarr_cm_tree-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zarr-cm-tree 0.2.0
File Interpreter ABI Platform Actions
zarr_cm_tree-0.2.0-py3-none-any.whl Python 3 none any Details for zarr_cm_tree-0.2.0-py3-none-any.whl

Total release size: 23.0 kB

Release files / zarr_cm_tree-0.2.0.tar.gz

Download URL zarr_cm_tree-0.2.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4f02c583b02a1b993bf406ba892b4543900e4d382e1f41a46c9cf2cd8703c1e0
BLAKE2b-256 checksum
How to use checksums
d0c5bb761c6ddf2bb903c663041816d0d6b1fe13b77211df65f2092bea1007df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / zarr_cm_tree-0.2.0-py3-none-any.whl

Download URL zarr_cm_tree-0.2.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d0f5fcd495c8cf8ceba646d237d67e597095e7051f732ca5c1d583b4998b89bf
BLAKE2b-256 checksum
How to use checksums
e211442260dff05f9b81cf72c46d0c33b2c073142050be703434e951acdd1f9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for zarr-cm-tree 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for zarr_cm_tree-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page