eotransform_xarray.sinks.combine_shards.CombineShards
- class CombineShards(canvas: DataArray, method: Method | None = Method.ASSIGN)[source]
Bases:
DataArraySinkCombine raster shards into one big canvas by assigning them to the canvas based on their exact coordinates. Different methods of assignment are supported.
>>> combined = CombineShards(DataArray([[0, 0, 0], ... [0, 0, 0], ... [0, 0, 0]], coords=dict(y=[0, 1, 2], x=[0, 1, 2]))) >>> combined(DataArray([[1, 1], ... [1, 1]], coords=dict(y=[0, 1], x=[0, 1]), attrs=dict(foo=1))) >>> combined(DataArray([[2, 2], ... [2, 2]], coords=dict(y=[1, 2], x=[1, 2]), attrs=dict(foo=2))) >>> combined.canvas <xarray.DataArray (y: 3, x: 3)> array([[1, 1, 0], [1, 2, 2], [0, 2, 2]]) Coordinates: * y (y) int64 0 1 2 * x (x) int64 0 1 2 Attributes: shard_attrs: [{'foo': 1}, {'foo': 2}]
- Parameters:
canvas – the raster to assign the shards to (needs to be in the same coordinate system)
method – the method used to apply shards to the canvas (default: assign). - Method.ASSIGN: directly assigns the shard data to the canvas overwriting previous ones. - Method.OR: or together the canvas and the shard. This requires boolean data.
Methods
Attributes
canvas