RasterioCRSTransformer#

class RasterioCRSTransformer[source]#

Bases: CRSTransformer

Transformer for a RasterioRasterSource.

__init__(transform: Affine, image_crs: Any, map_crs: Any = 'epsg:4326', round_pixels: bool = True)[source]#

Constructor.

Parameters:
  • transform (Affine) – Rasterio affine transform.

  • image_crs (Any) – CRS of image in format that PyProj can handle eg. wkt or init string.

  • map_crs (Any) – CRS of the labels. Defaults to “epsg:4326”.

  • round_pixels (bool) – If True, round outputs of map_to_pixel and inputs of pixel_to_map to integers. Defaults to False.

Methods

__init__(transform, image_crs[, map_crs, ...])

Constructor.

from_dataset(dataset[, map_crs])

Build from rasterio dataset.

from_uri(uri[, map_crs])

Build from raster URI.

map_to_pixel(inp[, bbox])

Transform input from map to pixel coords.

pixel_to_map(inp[, bbox])

Transform input from pixel to map coords.

__init__(transform: Affine, image_crs: Any, map_crs: Any = 'epsg:4326', round_pixels: bool = True)[source]#

Constructor.

Parameters:
  • transform (Affine) – Rasterio affine transform.

  • image_crs (Any) – CRS of image in format that PyProj can handle eg. wkt or init string.

  • map_crs (Any) – CRS of the labels. Defaults to “epsg:4326”.

  • round_pixels (bool) – If True, round outputs of map_to_pixel and inputs of pixel_to_map to integers. Defaults to False.

classmethod from_dataset(dataset: Any, map_crs: str | None = 'epsg:4326', **kwargs) IdentityCRSTransformer | Self[source]#

Build from rasterio dataset.

Parameters:
  • dataset (Any) – Rasterio dataset.

  • map_crs (str | None) – Target map CRS. Defaults to ‘epsg:4326’.

  • **kwargs – Extra args for __init__().

Return type:

IdentityCRSTransformer | Self

classmethod from_uri(uri: str, map_crs: str | None = 'epsg:4326', **kwargs) IdentityCRSTransformer | Self[source]#

Build from raster URI.

Parameters:
  • uri (str) – Raster URI.

  • map_crs (str | None) – Target map CRS. Defaults to ‘epsg:4326’.

  • **kwargs – Extra args for __init__().

Return type:

IdentityCRSTransformer | Self

map_to_pixel(inp, bbox: rastervision.core.box.Box | None = None)#

Transform input from map to pixel coords.

Parameters:
  • inp – (x, y) tuple or Box or shapely geometry in map coordinates. If tuple, x and y can be single values or array-like.

  • bbox (rastervision.core.box.Box | None) – If the extent of the associated RasterSource is constrained via a bbox, it can be passed here to get an output that is in coordinates of the bbox rather than the full extent of the data source of the RasterSource. Defaults to None.

Returns:

Coordinate-transformed input in the same format.

pixel_to_map(inp, bbox: rastervision.core.box.Box | None = None)#

Transform input from pixel to map coords.

Parameters:
  • inp – (x, y) tuple or Box or shapely geometry in pixel coordinates. If tuple, x and y can be single values or array-like.

  • bbox (rastervision.core.box.Box | None) – If the extent of the associated RasterSource is constrained via a bbox, it can be passed here so that the input is interpreted to be in coordinates of the bbox rather than the full extent of the data source of the RasterSource. Defaults to None.

Returns:

Coordinate-transformed input in the same format.