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: Optional[str] = 'epsg:4326', **kwargs) Union[IdentityCRSTransformer, RasterioCRSTransformer][source]#

Build from rasterio dataset.

Parameters
  • dataset (Any) – Rasterio dataset.

  • map_crs (Optional[str]) – Target map CRS. Defaults to ‘epsg:4326’.

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

Return type

Union[IdentityCRSTransformer, RasterioCRSTransformer]

classmethod from_uri(uri: str, map_crs: Optional[str] = 'epsg:4326', **kwargs) Union[IdentityCRSTransformer, RasterioCRSTransformer][source]#

Build from raster URI.

Parameters
  • uri (Any) – Raster URI.

  • map_crs (Optional[str]) – Target map CRS. Defaults to ‘epsg:4326’.

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

Return type

Union[IdentityCRSTransformer, RasterioCRSTransformer]

map_to_pixel(inp, bbox: Optional[Box] = 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 (Optional[Box]) – 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: Optional[Box] = 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 (Optional[Box]) – 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.