SemanticSegmentationLabelSource#

class SemanticSegmentationLabelSource[source]#

Bases: LabelSource

A read-only label source for semantic segmentation.

Attributes

bbox

Bounding box applied to the source.

crs_transformer

Associated CRSTransformer.

extent

Extent of the LabelSource.

__init__(raster_source: RasterSource, class_config: ClassConfig, bbox: Optional[Box] = None)[source]#

Constructor.

Parameters
  • raster_source (RasterSource) – A raster source that returns a single channel raster with class_ids as values.

  • null_class_id (int) – the null class id used as fill values for when windows go over the edge of the label array. This can be retrieved using class_config.null_class_id.

  • bbox (Optional[Box], optional) – User-specified crop of the extent. If None, the full extent available in the source file is used.

  • class_config (ClassConfig) –

Methods

__init__(raster_source, class_config[, bbox])

Constructor.

get_label_arr([window])

Get labels for a window.

get_labels([window])

Get labels for a window.

set_bbox(bbox)

Set self.extent to the given value.

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

key (Any) –

Return type

Any

__init__(raster_source: RasterSource, class_config: ClassConfig, bbox: Optional[Box] = None)[source]#

Constructor.

Parameters
  • raster_source (RasterSource) – A raster source that returns a single channel raster with class_ids as values.

  • null_class_id (int) – the null class id used as fill values for when windows go over the edge of the label array. This can be retrieved using class_config.null_class_id.

  • bbox (Optional[Box], optional) – User-specified crop of the extent. If None, the full extent available in the source file is used.

  • class_config (ClassConfig) –

get_label_arr(window: Optional[Box] = None) ndarray[source]#

Get labels for a window.

The returned array will be the same size as the input window. If window overflows the extent, the overflowing region will be filled with the ID of the null class as defined by the class_config.

Parameters

window (Optional[Box], optional) – Window (in pixel coords) to get labels for. If None, returns a label array covering the full extent of the scene.

Returns

Label array.

Return type

np.ndarray

get_labels(window: Optional[Box] = None) SemanticSegmentationLabels[source]#

Get labels for a window.

Parameters
  • window (Optional[Box], optional) – Window to get labels for. If

  • None

  • scene. (returns labels covering the full extent of the) –

Returns

The labels.

Return type

SemanticSegmentationLabels

set_bbox(bbox: Box) None[source]#

Set self.extent to the given value.

Note

This method is idempotent.

Parameters
  • extent (Box) – User-specified extent in pixel coordinates.

  • bbox (Box) –

Return type

None

property bbox: Box#

Bounding box applied to the source.

property crs_transformer: CRSTransformer#

Associated CRSTransformer.

property extent: Box#

Extent of the LabelSource.