RasterSource#

class RasterSource[source]#

Bases: ABC

A source of raster data.

This should be subclassed when adding a new source of raster data such as a set of files, an API, a TMS URI schema, etc.

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.

shape

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

__init__(channel_order: Optional[List[int]], num_channels_raw: int, raster_transformers: List[RasterTransformer] = [], extent: Optional[Box] = None)[source]#

Constructor.

Parameters
  • channel_order (Optional[List[int]]) – list of channel indices to use when extracting chip from raw imagery.

  • num_channels_raw (int) – Number of channels in the raw imagery before applying channel_order.

  • raster_transformers (List[RasterTransformer]) – RasterTransformers for transforming chips whenever they are retrieved. Defaults to [].

  • extent (Optional[Box]) – Use-specified extent. If None, the full extent of the raster source is used.

Methods

__init__(channel_order, num_channels_raw[, ...])

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.

__init__(channel_order: Optional[List[int]], num_channels_raw: int, raster_transformers: List[RasterTransformer] = [], extent: Optional[Box] = None)[source]#

Constructor.

Parameters
  • channel_order (Optional[List[int]]) – list of channel indices to use when extracting chip from raw imagery.

  • num_channels_raw (int) – Number of channels in the raw imagery before applying channel_order.

  • raster_transformers (List[RasterTransformer]) – RasterTransformers for transforming chips whenever they are retrieved. Defaults to [].

  • extent (Optional[Box]) – Use-specified extent. If None, the full extent of the raster source is used.

get_chip(window: Box) np.ndarray[source]#

Return the transformed chip in the window.

Get a raw chip, extract subset of channels using channel_order, and then apply transformations.

Parameters

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

Returns

Array of shape (height, width, channels).

Return type

np.ndarray

get_image_array() np.ndarray[source]#

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[source]#

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[source]#

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

abstract property crs_transformer: CRSTransformer#

Associated CRSTransformer.

abstract property dtype: np.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 shape: Tuple[int, int, int]#

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