Concepts¶
zarr-vectors-tools is organised around four workflows that compose over
a shared on-disk format:
┌──────────┐ ┌────────────────┐ ┌──────────────┐ ┌──────────┐
│ source │──▶│ ingest_<fmt>() │──▶│ Zarr Vectors │──▶│ export_ │──▶ output
│ file │ │ + enrichments │ │ store │ │ <fmt>() │ file
└──────────┘ └────────────────┘ └──────┬───────┘ └──────────┘
│ ▲
┌──────────────┘ └──────────────┐
▼ │
┌───────────────────┐ ┌────────────────────────┐
│ build_pyramid() │ │ compute_*() algorithm │
│ coarser levels │ │ (may write attributes │
└───────────────────┘ │ back to the store) │
└────────────────────────┘
Every public entry point in this package either:
Reads a file format and writes a store (
zarr_vectors_tools.convert.ingest),Coarsens a store into additional resolution levels (
zarr_vectors_tools.multiresolution),Computes over a store and optionally writes results back (
zarr_vectors_tools.algorithms), orReads a store and writes a file format (
zarr_vectors_tools.convert.export).
Important
This page describes this package’s workflows only. The format they
operate on — stores, chunks, bins, fragments, links, the object model — is
owned and documented by
zarr-vectors-py.
Start at Core concepts, and see
How this package relates to zarr-vectors-py for the
division of labour.
Relationship to zarr-vectors-py¶
The format itself, the chunk encoding, the spatial index, links, and lazy access all live in the parent package and are documented there. What this package consumes from it:
The store-creating writers and per-chunk write helpers on the supported
zarr_vectors.buildingsurface (the building API), which every ingest path and every write-back path here routes through.The
zarr_vectors.apisurface (the data API) for reading.A basic multiresolution layer —
per_objectbinning plusrandomobject selection — and a plug-in strategy registry.
This package adds:
File-format wrappers — each ingest module wraps a third-party reader (
laspy,nibabel,plyfile,networkx,trx-python,cloud-volume) or a pure-Python parser (OBJ, STL, SWC) and feeds the result into the appropriate writer.Enrichment helpers — per-vertex and per-object attributes derived during ingest: vertex counts, polyline lengths, kNN distances, Strahler order. See Enrichments.
The rich multiresolution layer — skeleton and polyline coarseners, spatial-coverage / length / attribute / point-thinning selection, cross-level links. See Multiresolution.
Streaming algorithms — graph search, connected components, community detection, mesh summary, vertex normals, mean curvature, closest-point and ray queries. None materialise the whole store; all walk the chunk grid or the object manifests on demand.
The
zvtoolsCLI. See ThezvtoolsCLI.
How the multiresolution split works¶
Importing zarr_vectors_tools has a side effect: it registers this
package’s coarseners (skeleton, polyline) and selectors
(spatial_coverage, length, attribute, point_thinning) into the
parent package’s strategy registry, through its supported
zarr_vectors.building.register_coarsen_strategy and
register_selection_strategy entry points.
That is what lets the parent package dispatch into tools without taking
a dependency on it. Ask what an installation has with
zarr_vectors.coarsen_methods():
import zarr_vectors as zv
zv.coarsen_methods() # ('per_object',)
import zarr_vectors_tools # noqa: F401
zv.coarsen_methods() # ('per_object', 'polyline', 'skeleton')
The registration degrades silently on a core too old to have the registry.
One thing is deliberately not wired up: pyramid refresh. The parent
package’s editing path (ds.editing(refresh_pyramid=True)) uses its own
basic refresher. To get the rich re-coarsening after an edit, call
rebuild_pyramid_from_level yourself.
Geometry types and which ingest goes with which¶
Geometry type |
Ingest functions |
|---|---|
point cloud |
|
line |
|
polyline / streamline |
|
graph |
|
skeleton (tree) |
|
mesh |
|
The export modules cover the formats most users round-trip back to: CSV, PLY, TRK, TRX, SWC, OBJ.
Warning
Neither zarr_vectors_tools.convert.ingest nor zarr_vectors_tools.convert.export has
re-exports — their __init__.py files are empty. Always import from the
concrete module:
from zarr_vectors_tools.convert.ingest.csv_points import ingest_csv # correct
from zarr_vectors_tools.convert.ingest import ingest_csv # ImportError
zarr_vectors_tools.algorithms does re-export, so
from zarr_vectors_tools.algorithms import bfs_distances is fine.
Chunk shape and bin shape¶
Ingest writers take a required chunk_shape and an optional bin_shape.
Both are format-level concepts owned by the parent package — what they
mean, how they interact, and how to size them are specified at
chunk shape,
bin shape and
chunk versus bin, with the sizing reasoning at
Choosing chunk and bin shape.
What is specific to this package is only how those values are supplied to an ingest, and the one path that derives them for you:
Every ingest function takes
chunk_shapeexplicitly, andbin_shapeoptionally.The
trkpath is the exception: it takes--num-chunks(a target chunk count) instead of an explicit shape, and derives the shape from the data bounds.
See Choosing chunk and bin shape for the flags this package adds on top.
What lives where on disk¶
The on-disk layout is specified by the parent package, not here. Read it at Directory structure, with the two metadata documents at root metadata and level metadata, and connectivity at Links.
This release targets on-disk format version 0.9.0.
You should not need to touch any of it directly. The ingest, pyramid,
algorithm and export functions in this package handle every read and write
through the supported zarr_vectors.api and zarr_vectors.building
surfaces.
Warning
One layout fact is worth repeating here because it changes how algorithm
code in this package must be written: at format 0.9.0 all
connectivity lives in a single links/ family, so a read returns the whole
family. The old idiom of reading per-chunk links and then adding
cross-chunk links counts every intra-chunk edge twice. See the double-count
trap in Algorithms.
Headers¶
Several formats carry metadata that is not part of the geometry: TRK
voxel-to-RAS affines, SWC coordinate_space comments, OBJ object names,
CSV normalisation parameters. Ingest preserves these into a
headers/<format>/ group on the store.
Warning
Recovering a header on export is manual. No exporter reads
headers/ automatically — in particular export_trk(affine=None) writes
an identity affine, not the affine that was stored at ingest, which
silently produces a misregistered tractogram. Read the header yourself
and pass it in. See Headers and
Exporting streamlines.
See also¶
How this package relates to
zarr-vectors-py— the division of labour.Quickstart — concrete code for each workflow.
Modules — what each subpackage owns.
Parent package: Core concepts — the format itself.
Parent package: the specification — the normative specification.