MultiRasterSource#
- class MultiRasterSource[source]#
Bases:
RasterSource
Merge multiple
RasterSources
by concatenating along channel dim.Attributes
Bounding box applied to the source imagery.
Associated
CRSTransformer
.numpy.dtype
of the chips read from this source.Extent of the
RasterSource
.Number of channels in the chips read from this source.
Primary sub-
RasterSource
Shape of the raster as a (..., H, W, C) 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 = [], bbox: 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 [].
bbox (Optional[Box], optional) – 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.
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 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 = [], bbox: 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 [].
bbox (Optional[Box], optional) – 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.
- get_chip(window: Box, out_shape: Optional[Tuple[int, int]] = 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), concatenate them along the channel dimension, apply channel_order, followed by transformations.
- get_chip_by_map_window(window_map_coords: Box, out_shape: Optional[Tuple[int, int]] = None) ndarray #
Same as get_chip(), but input is a window in map coords.
- get_raw_chip(window: Box, out_shape: Optional[Tuple[int, int]] = None) ndarray #
Return raw chip without applying channel_order or transforms.
- 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 [source]#
Validate sub-
RasterSources
.Checks if:
dtypes are same or
force_same_dtype
is True.
- Return type
None
- property crs_transformer: CRSTransformer#
Associated
CRSTransformer
.
- property primary_source: RasterSource#
Primary sub-
RasterSource