MultiRasterSource#

class MultiRasterSource[source]#

Bases: RasterSource

Merge multiple RasterSources by concatenating along channel dim.

Attributes

crs_transformer

Associated CRSTransformer.

dtype

numpy.dtype of the chips read from this source.

extent

Extent of the RasterSource.

num_channels

Number of channels in the chips read from this source.

primary_source

Primary sub-RasterSource

shape

Shape of the raster as a (height, width, num_channels) tuple.

__init__(raster_sources: Sequence[RasterSource], primary_source_idx: ConstrainedIntValue = 0, force_same_dtype: bool = False, channel_order: Optional[Sequence[ConstrainedIntValue]] = None, raster_transformers: Sequence = [], extent: Optional[Box] = None)[source]#

Constructor.

Parameters
  • raster_sources (Sequence[RasterSource]) – Sequence of RasterSources.

  • primary_source_idx (0 <= int < len(raster_sources)) – Index of the raster source whose CRS, dtype, and other attributes will override those of the other raster sources.

  • force_same_dtype (bool) – If true, force all sub-chips to have the same dtype as the primary_source_idx-th sub-chip. No careful conversion is done, just a quick cast. Use with caution.

  • channel_order (Sequence[conint(ge=0)], optional) – Channel ordering that will be used by .get_chip(). Defaults to None.

  • raster_transformers (Sequence, optional) – Sequence of transformers. Defaults to [].

  • extent (Optional[Box]) –

Methods

__init__(raster_sources[, ...])

Constructor.

get_chip(window)

Return the transformed chip in the window.

get_image_array()

Return entire transformed image array.

get_raw_chip(window)

Return raw chip without applying channel_order or transforms.

get_raw_image_array()

Return raw image for the full extent.

validate_raster_sources()

Validate sub-RasterSources.

__init__(raster_sources: Sequence[RasterSource], primary_source_idx: ConstrainedIntValue = 0, force_same_dtype: bool = False, channel_order: Optional[Sequence[ConstrainedIntValue]] = None, raster_transformers: Sequence = [], extent: Optional[Box] = None)[source]#

Constructor.

Parameters
  • raster_sources (Sequence[RasterSource]) – Sequence of RasterSources.

  • primary_source_idx (0 <= int < len(raster_sources)) – Index of the raster source whose CRS, dtype, and other attributes will override those of the other raster sources.

  • force_same_dtype (bool) – If true, force all sub-chips to have the same dtype as the primary_source_idx-th sub-chip. No careful conversion is done, just a quick cast. Use with caution.

  • channel_order (Sequence[conint(ge=0)], optional) – Channel ordering that will be used by .get_chip(). Defaults to None.

  • raster_transformers (Sequence, optional) – Sequence of transformers. Defaults to [].

  • extent (Optional[Box]) –

get_chip(window: Box) ndarray[source]#

Return the transformed chip in the window.

Get processed chips from sub raster sources (with their respective channel orders and transformations applied), concatenate them along the channel dimension, apply channel_order, followed by transformations.

Parameters

window (Box) – Box

Returns

np.ndarray with shape [height, width, channels]

Return type

ndarray

get_image_array() np.ndarray#

Return entire transformed image array.

Warning

Not safe to call on very large RasterSources.

Returns

Array of shape (height, width, channels).

Return type

np.ndarray

get_raw_chip(window: Box) np.ndarray#

Return raw chip without applying channel_order or transforms.

Parameters

window (Box) – The window for which to get the chip.

Returns

Array of shape (height, width, channels).

Return type

np.ndarray

get_raw_image_array() np.ndarray#

Return raw image for the full extent.

Warning

Not safe to call on very large RasterSources.

Returns

Array of shape (height, width, channels).

Return type

np.ndarray

validate_raster_sources() None[source]#

Validate sub-RasterSources.

Checks if:

  • dtypes are same or force_same_dtype is True.

  • each sub-RasterSource is a RasterioSource if extents not identical.

Return type

None

property crs_transformer: CRSTransformer#

Associated CRSTransformer.

property dtype: dtype#

numpy.dtype of the chips read from this source.

property extent: Box#

Extent of the RasterSource.

property num_channels: int#

Number of channels in the chips read from this source.

property primary_source: RasterSource#

Primary sub-RasterSource

property shape: Tuple[int, int, int]#

Shape of the raster as a (height, width, num_channels) tuple.