RasterizedSource#
- class RasterizedSource[source]#
Bases:
RasterSource
A
RasterSource
based on the rasterization of a VectorSource.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.
Shape of the raster as a (height, width, num_channels) tuple.
- __init__(vector_source: VectorSource, background_class_id: int, bbox: Box | None = None, all_touched: bool = False, raster_transformers: list['RasterTransformer'] = [])[source]#
Constructor.
- Parameters:
vector_source (VectorSource) – The VectorSource to rasterize.
background_class_id (int) – The class_id to use for any background pixels, ie. pixels not covered by a polygon.
bbox (Box | None) – User-specified crop of the extent. If None, the full extent available in the source file is used.
all_touched (bool) – If True, all pixels touched by geometries will be burned in. If false, only pixels whose center is within the polygon or that are selected by Bresenham’s line algorithm will be burned in. (See
rasterize()
for more details). Defaults to False.raster_transformers (list['RasterTransformer']) –
Methods
__init__
(vector_source, background_class_id)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_labels
(df)Validate label geometries.
- __init__(vector_source: VectorSource, background_class_id: int, bbox: Box | None = None, all_touched: bool = False, raster_transformers: list['RasterTransformer'] = [])[source]#
Constructor.
- Parameters:
vector_source (VectorSource) – The VectorSource to rasterize.
background_class_id (int) – The class_id to use for any background pixels, ie. pixels not covered by a polygon.
bbox (Box | None) – User-specified crop of the extent. If None, the full extent available in the source file is used.
all_touched (bool) – If True, all pixels touched by geometries will be burned in. If false, only pixels whose center is within the polygon or that are selected by Bresenham’s line algorithm will be burned in. (See
rasterize()
for more details). Defaults to False.raster_transformers (list['RasterTransformer']) –
- get_chip(window: Box, out_shape: tuple[int, int] | None = None) ndarray #
Return the transformed chip in the window.
Get a raw chip, extract subset of channels using channel_order, and then apply transformations.
- get_chip_by_map_window(window_map_coords: Box, *args, **kwargs) ndarray #
Same as get_chip(), but input is a window in map coords.
- get_raw_chip(window: Box, out_shape: tuple[int, int] | None = 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_labels(df: GeoDataFrame) None [source]#
Validate label geometries.
- Parameters:
df (gpd.GeoDataFrame) – Label geometries.
- Raises:
ValueError – If
Point
orLineString
geometries found.ValueError – If geometries are missing class IDs.
- Return type:
None
- property crs_transformer#
Associated
CRSTransformer
.