Root metadata¶
This page lists every key in the root attributes of a Zarr Vectors store.
Terms¶
- Root attributes
The
attributesof the rootzarr.json. They hold four keys:zarr_conventions,zarr_vectors,multiscalesandome, and optionallyproj:projjsonanduser_metadata.- Convention registration
An entry in
zarr_conventionsnaming a convention the node follows. Format 0.10.0 stores its metadata as the Zarr Vectors convention (v0.1.0), and every node that carries azarr_vectorsattribute registers it.- Capability token
A string in
format_capabilitiesorrequired_capabilitiesnaming an optional feature the store uses. The tokens are theCAP_*constants inzarr_vectors.constants.
Introduction¶
The zarr_vectors object, with kind "root", says what the store
holds and how it is laid out, including its axes. multiscales lists the
levels. ome lets an OME collection name the store by path. Per-level
facts are in each level’s attributes.
read_root_metadata(root) in zarr_vectors.core.store returns a
RootMetadata (zarr_vectors.core.metadata), with defaults filled in for
absent keys.
Technical reference¶
Example¶
The root attributes of a three-level streamline pyramid
(write_polylines with chunk_shape=(200, 200, 200) and
bin_shape=(50, 50, 50), then build_pyramid(..., factors=[(2, 2), (2, 2)])):
{
"zarr_conventions": [
{"uuid": "66268a61-7833-4995-bbcb-233bb417dae5", "name": "zarr_vectors", ...},
{"uuid": "d35379db-88df-4056-af3a-620245f8e347", "name": "multiscales", ...}
],
"zarr_vectors": {
"kind": "root",
"zv_version": "0.10.0",
"axes": [
{"name": "x", "type": "space"},
{"name": "y", "type": "space"},
{"name": "z", "type": "space"}
],
"format_capabilities": ["preserved_object_ids", "shared_fragments", "multiscale_links"],
"chunk_shape": [200.0, 200.0, 200.0],
"bounds": [[0.0, 0.0, 0.0], [400.0, 400.0, 400.0]],
"geometry_types": ["streamline"],
"base_bin_shape": [50.0, 50.0, 50.0],
"links_convention": "implicit_sequential",
"object_index_convention": "standard",
"cross_chunk_strategy": "explicit_links",
"cross_level_depth": 1,
"cross_level_storage": "explicit"
},
"multiscales": {"layout": [{"asset": "0"}, {"asset": "1"}, {"asset": "2"}]},
"ome": {"version": "0.6", "type": "collection", "name": "streamline_pyr", "nodes": [...], ...}
}
zarr_vectors keys¶
Always written:
Key |
Type |
Meaning |
|---|---|---|
|
string |
|
|
string |
Format version of the writer, |
|
list of objects |
One |
|
list of strings |
Capability tokens the store uses; |
|
list of numbers |
Spatial extent of one chunk per axis; see Chunk shape |
|
|
Spatial bounds the chunk grid covers. |
|
list of strings |
|
Written when set; a reader uses the default when absent:
Key |
Type |
Default |
Meaning |
|---|---|---|---|
|
list of numbers |
|
Bin shape at level 0; see Bin shape |
|
string |
|
|
|
string |
|
|
|
string |
|
|
|
integer |
|
Largest level delta of cross-level links |
|
string |
|
|
|
integer |
|
Pyramid reduction factor, at least 2 |
|
object |
none |
Declared attributes by scope ( |
|
integer or list |
unsharded |
Cells per shard per axis; see Sharding |
|
object |
|
Configuration of the |
|
string |
|
Written only as |
|
string |
|
Written only as |
|
list of strings |
|
Capabilities a reader must implement to read the store |
|
list of numbers |
zeros |
World position of the stored origin: world = stored + offset. Written by |
There is no crs key. A coordinate reference system is the root
attribute proj:projjson; see below.
Capability tokens¶
Token |
Added when |
|---|---|
|
A level keeps object IDs stable across levels ( |
|
A level’s fragments may be named by more than one object |
|
The store may hold cross-level links ( |
|
|
|
|
|
A level has octree chunks; also in |
|
Not added by any writer |
octree_chunks is the only token written to required_capabilities. The
reader does not refuse a store that requires a capability it lacks.
zarr_conventions¶
The root registers the Zarr Vectors convention with its full entry:
{
"schema_url": "https://raw.githubusercontent.com/Andrew-Keenlyside/zarr-vectors/refs/tags/v0.1.0/schema.json",
"spec_url": "https://github.com/Andrew-Keenlyside/zarr-vectors/blob/v0.1.0/README.md",
"uuid": "66268a61-7833-4995-bbcb-233bb417dae5",
"name": "zarr_vectors",
"description": "Spatially chunked, multi-resolution N-dimensional vector data (point clouds, meshes, skeletons, streamlines, graphs)"
}
It also registers the
multiscales convention
(uuid d35379db-88df-4056-af3a-620245f8e347) and, when the store has a
CRS, the proj convention
(uuid f17cb550-5864-4468-aeb7-f3180cfb622f). Every other node with a
zarr_vectors attribute registers the short form
{"uuid": "66268a61-7833-4995-bbcb-233bb417dae5"}. A writer keeps
entries for other conventions that are already there.
multiscales, proj:projjson and ome¶
multiscales is the multiscales convention’s block, with one layout
entry per level: {"layout": [{"asset": "0"}, {"asset": "1"}, ...]}.
It has no transform, because every level stores vertices in level-0
coordinates. A coarser level’s bin_ratio and bin_shape are in its
level attributes. See
Multiscale metadata.
proj:projjson holds the coordinate reference system given to
create_store(crs=...), as a PROJJSON object. It is absent when the store
has no CRS.
ome is an RFC 8 collection node (version "0.6", type
"collection"). Its name is the store’s directory name without
extension, unless create_store(name=...) sets one. It holds the axes as
one coordinate system named world, and one
{"type": "zv:level", "name": "<n>"} node per level. Nothing in this
package reads ome, and a store without it is valid.
zarr_vectors.building.stamp_ome_node(store) adds it without rewriting
data.
Reading root metadata¶
from zarr_vectors.core.store import open_store, read_root_metadata
root = open_store("tracts.zarrvectors")
meta = read_root_metadata(root)
meta.geometry_types # ['streamline']
meta.effective_bin_shape # (50.0, 50.0, 50.0)
meta.reduction_factor # 8, the default: the key is absent
read_root_metadata raises MetadataError when zv_version,
chunk_shape, bounds, geometry_types or axes is missing. It raises
UnsupportedFormatVersionError (a MetadataError) for a 0.9.x store,
whose root zarr_vectors object has no kind, and for a store newer
than 0.10; see Migrating from 0.9.x below.
To change the block after creation, use set_bounds(root, bounds)
(shrinking needs force=True) and
update_root_metadata(root, add_capabilities=[...], **fields) from
zarr_vectors.core.store rather than editing the attributes directly.
user_metadata¶
Application metadata goes under user_metadata, one namespace per
application, never in zarr_vectors. Dataset.metadata["myapp"]
reads and writes attributes["user_metadata"]["myapp"]. The library
does not read or validate it.
Validation¶
L1 fails a store with no zarr_vectors
key and warns when there is no ome key.
L2 checks that:
chunk_shapeandboundshave one entry per axis, andchunk_shapeentries are positive;links_convention,object_index_conventionandcross_chunk_strategyare known values;base_bin_shape, when present, has one positive entry per axis, each a whole fraction ofchunk_shape(tolerance1e-9);geometry_typesis not empty, andoctree_chunksis in both capability lists exactly while a level has octree chunks (warnings).
L2 also runs RootMetadata.validate() (readers do not), which
requires zv_version of at least 0.10.0, at least two space axes with
unique names, reduction_factor of at least 2, known cross_level_storage,
manifest_layout and manifest_block_dtype values, and shard_shape
whenever octree_sharding is set.
Migrating from 0.9.x¶
Format 0.10.0 moves metadata; every cell is byte-for-byte as in 0.9.4.
This package refuses a 0.9.x store with UnsupportedFormatVersionError.
Migrate it in place, rewriting only zarr.json files:
from zarr_vectors.building import migrate_metadata_0_10
migrate_metadata_0_10("tracts.zarrvectors", dry_run=True) # counts only
migrate_metadata_0_10("tracts.zarrvectors")
It returns the number of nodes rewritten by role. The root is rewritten last, so an interrupted run leaves a store that is still refused as 0.9.x, and running it again finishes the job. On a 0.10.0 store it changes nothing and returns zeros.
0.9.x |
0.10.0 |
|---|---|
Root |
The same object with |
Root |
Root |
Root |
Root |
Root |
|
Level |
Level |
Level |
The level object’s |
Array |
|
|
|
|
|
|
|
No registration |
|
A coarse level whose bins were only in its old NGFF entry gets them
copied into its level object (bin_ratio = scale, bin_shape = 2 ×
translation). A 0.9.x reader cannot read a migrated store.