Stacks and domains¶
Stack
¶
Stack(
layers: Optional[List[Layer]] = None,
tile_meta: Optional[TileMeta] = None,
position: Optional[Tuple] = None,
)
An ordered collection of data layers.
Access layers by index (stack[0]) or by name (stack.read("Layer name")).
Further indices are spatial, as with NumPy arrays: stack[:, 50:150] selects rows
50 to 150 of all layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layers
|
list of Layer
|
Initial layers of the stack. |
None
|
tile_meta
|
TileMeta
|
Metadata about the stack's position and role in a set of tiles. |
None
|
position
|
tuple
|
Position of the stack in global pixel coordinates. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
layers |
list of Layer
|
The layers in the stack. |
position |
tuple
|
Position of the stack in global pixel coordinates. Setting it offsets the positions of all layers. |
extent |
Domain
|
Smallest region containing all layers, in global pixel coordinates. |
size |
tuple
|
Size of the extent. |
coords_min |
tuple
|
Lower corner of the extent. |
coords_max |
tuple
|
Upper corner of the extent. |
ndim |
int
|
Number of spatial dimensions of the extent. |
tile_meta |
TileMeta
|
Metadata about the stack's position and role in a set of tiles. |
add
¶
read
¶
read(name: str) -> Optional[Layer]
Get a layer by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the layer. |
required |
Returns:
| Type | Description |
|---|---|
Layer or None
|
The layer, or |
delete
¶
Delete a layer by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the layer to delete. |
required |
select
¶
merge
¶
Merge another stack into this one, in place.
Incoming layers with the same name as an existing layer are merged into that layer, following the merging strategy of the layer type. Other incoming layers are added to the stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stack
|
Stack
|
The stack to merge. If |
required |
reinitialize_domain
|
Domain
|
A region of the existing layers to reinitialize before merging the first tile of the incoming stack. |
None
|
Domain
¶
An n-D box defined by a size and a position in global pixel coordinates.
Domains represent regions of interest and tile extents, and are used to restrict the computation of an algorithm to a region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
tuple
|
Size of the domain in pixels, one value per dimension. |
None
|
position
|
tuple
|
Position of the lower corner of the domain (top-left in 2D), in global pixel
coordinates. Defaults to the origin if only |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
size |
tuple
|
Size of the domain in pixels. |
coords_min |
tuple
|
Lower corner of the domain (top-left in 2D). |
coords_max |
tuple
|
Upper corner of the domain (bottom-right in 2D). |
ndim |
int
|
Number of dimensions. |
Examples:
merge_layers
¶
Merge a list of data layers of the same kind into a new layer.
The layers are merged as successive tiles, following the merging strategy of the layer type (see the "Merging tiles" section of the documentation). The input layers are not modified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layers
|
list of Layer
|
The layers to merge. They must all be of the same kind. |
required |
Returns:
| Type | Description |
|---|---|
Layer
|
A new layer containing the merged data. If a single layer is given, it is returned as is. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |