TemporalMultiRasterSource#

class TemporalMultiRasterSource[source]#

Bases: MultiRasterSource

Merge multiple RasterSources by stacking them along a new dim.

Attributes

bbox

Bounding box applied to the source imagery.

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 (..., H, W, C) tuple.

__init__(raster_sources: Sequence[RasterSource], primary_source_idx: int = 0, raster_transformers: Sequence[RasterTransformer] = [], bbox: rastervision.core.box.Box | None = None)[source]#

Constructor.

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

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

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

  • bbox (rastervision.core.box.Box | None) – User-specified crop of the extent. If given, the primary raster source’s bbox is set to this. If None, the full extent available in the source file of the primary raster source is used.

Methods

__init__(raster_sources[, ...])

Constructor.

from_stac(*args, **kwargs)

Not implemented for TemporalMultiRasterSource.

get_chip(window[, out_shape])

Return the transformed chip in the window.

get_chip_by_map_window(window_map_coords, ...)

Same as get_chip(), but input is a window in map coords.

get_raw_chip(window[, out_shape])

Return raw chip without applying channel_order or transforms.

resize(chip[, out_shape])

set_bbox(bbox)

Set self.bbox to the given value.

validate_raster_sources()

Validate sub-RasterSources.

__getitem__(key: Any) ndarray[source]#
Parameters:

key (Any) –

Return type:

ndarray

__init__(raster_sources: Sequence[RasterSource], primary_source_idx: int = 0, raster_transformers: Sequence[RasterTransformer] = [], bbox: rastervision.core.box.Box | None = None)[source]#

Constructor.

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

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

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

  • bbox (rastervision.core.box.Box | None) – User-specified crop of the extent. If given, the primary raster source’s bbox is set to this. If None, the full extent available in the source file of the primary raster source is used.

classmethod from_stac(*args, **kwargs)[source]#

Not implemented for TemporalMultiRasterSource.

get_chip(window: Box, out_shape: tuple[int, int] | None = None) ndarray[source]#

Return the transformed chip in the window.

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

Parameters:
  • window (Box) – The window for which to get the chip, in pixel coordinates.

  • out_shape (tuple[int, int] | None) – (height, width) to resize the chip to.

Returns:

4D array of shape (T, H, W, C).

Return type:

np.ndarray

get_chip_by_map_window(window_map_coords: Box, *args, **kwargs) ndarray#

Same as get_chip(), but input is a window in map coords.

Parameters:

window_map_coords (Box) –

Return type:

ndarray

get_raw_chip(window: Box, out_shape: tuple[int, int] | None = None) ndarray#

Return raw chip without applying channel_order or transforms.

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

  • out_shape (tuple[int, int] | None) –

Returns:

Array of shape (…, height, width, channels).

Return type:

np.ndarray

resize(chip: ndarray, out_shape: tuple[int, int] | None = None) ndarray#
Parameters:
Return type:

ndarray

set_bbox(bbox: Box) None#

Set self.bbox to the given value.

Note

This method is idempotent.

Parameters:

bbox (Box) – User-specified bbox in pixel coordinates.

Return type:

None

validate_raster_sources() None#

Validate sub-RasterSources.

Checks if all raster sources have the same dtype.

Return type:

None

property bbox: Box#

Bounding box applied to the source imagery.

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, int]#

Shape of the raster as a (…, H, W, C) tuple.