Line (line)¶
Terms¶
- Line segment
A pair of vertices
(A, B)joined by a straight edge. Each segment is one object. The type constant isGEOM_LINE,"line".- Split segment
A segment whose endpoints are in different chunks.
Introduction¶
The line type stores independent two-point segments, such as contact
sites, connectors or distance annotations. Each segment has its own
manifest, so segments can be read by ID. For paths of any length, use
polyline. What every type shares is on
Geometry types.
Technical reference¶
Arrays present¶
At level 0 of a store written by write_lines:
Path |
Present |
Description |
|---|---|---|
|
Always |
One manifest per segment |
|
When a segment is split |
One record per split segment |
|
With |
One row per endpoint |
|
With |
One row per segment |
Case |
Fragments |
Manifest |
Link |
|---|---|---|---|
Both endpoints in one chunk |
One fragment holding both vertices |
|
None |
Endpoints in chunks |
One single-vertex fragment in each chunk |
|
One record in |
Within each chunk, fragments are in segment order. The root attributes:
{"geometry_types": ["line"], "links_convention": "implicit_sequential", ...}
Write and read API¶
import numpy as np
from zarr_vectors.building import write_lines
from zarr_vectors.types.lines import read_lines
rng = np.random.default_rng(0)
starts = rng.uniform(0, 500, (1000, 3))
endpoints = np.stack([starts, starts + rng.normal(0, 20, (1000, 3))], axis=1).astype(np.float32)
strength = rng.uniform(0, 1, 1000).astype(np.float32)
summary = write_lines(
"contacts.zarrvectors",
endpoints, # (N, 2, D): one row per segment
chunk_shape=(100.0, 100.0, 100.0),
object_attributes={"strength": strength},
)
print(summary)
# {'line_count': 1000, 'chunk_count': 192, 'cross_chunk_count': 388}
result = read_lines("contacts.zarrvectors", object_ids=[0, 5, 42])
print(result["line_count"], result["endpoints"].shape) # 3 (3, 2, 3)
cross_chunk_count is the number of split segments. vertex_attributes=
takes (N, 2) or (N, 2, C) arrays, one value per endpoint. The
deprecated attributes= and line_attributes= names still work but warn.
read_lines returns endpoints (M, 2, D), vertex_attributes (every
attribute in the store) and line_count. A bbox= read keeps a segment
when either endpoint is inside the box.
Validation¶
Only the common checks apply.