ImageBase#

Main API Methods

This are most important functions to be used for image classes

ImageBase.project(coordinates[, crs_s, ...])

Project 3D coordinates into image pixel coordinates.

ImageBase.map_center_point([mapper, transformer])

Map the image center pixel to 3D coordinates.

ImageBase.map_footprint([points_per_edge, ...])

Map footprint of image to 3D.

ImageBase.map_points(points_image[, mapper, ...])

Map image pixel coordinates to 3D coordinates.

additional helpful Methods

ImageBase.from_dict(param_dict[, mapper])

Create an image model from a parameter dictionary.

ImageBase.position_to_crs(crs_t)

Return the image reference position in the target CRS.

Properties

ImageBase.type

Return the image model type.

ImageBase.param_dict

Return image parameters as a dictionary.

ImageBase.mapper

ImageBase.is_geo_referenced

Return whether the image is geo-referenced.

ImageBase.position_wgs84

ImageBase.position_wgs84_geojson

ImageBase.crs

Return the image world CRS.

ImageBase.crs_wkt

Return images CRS as wkt string

ImageBase.crs_proj4

Return images CRS as proj4 string

ImageBase.width

Return width of image (column number)

ImageBase.height

Return height of image (row number)

ImageBase.shape

Return shape of image as tuple(width, height)

class weitsicht.ImageBase(width: float | int, height: float | int, mapper: MappingBase | None = None, crs: CRS | None = None)[source]#

Base class for image models.

This base class defines a common API for projecting 3D coordinates into image pixel coordinates and mapping image pixels to 3D coordinates (via an optional MappingBase).

Coordinate system conventions: - Image pixel CRS: x points right, y points down (origin at top-left pixel edge). - World CRS: any cartesian CRS; for mapping it is usually best to use a projected CRS.

Subclasses must implement: - from_dict - type - param_dict - is_geo_referenced - center - position_to_crs - project - map_center_point - map_footprint - map_points

Parameters:
  • width (float | int)

  • height (float | int)

  • mapper (MappingBase | None)

  • crs (CRS | None)

__init__(width: float | int, height: float | int, mapper: MappingBase | None = None, crs: CRS | None = None)[source]#

Initialize the image base class.

Parameters:
  • width (float | int) – Image width in pixels.

  • height (float | int) – Image height in pixels.

  • mapper (MappingBase | None) – Mapping instance, defaults to None.

  • crs (CRS | None) – World CRS of the image, defaults to None.

property mapper: MappingBase | None#
abstractmethod classmethod from_dict(param_dict: dict, mapper: MappingBase | None = None) ImageBase[source]#

Create an image model from a parameter dictionary.

Implementations should accept the dictionary returned by param_dict.

Parameters:
  • param_dict (dict) – Dictionary with image parameters.

  • mapper (MappingBase | None) – Mapping instance, defaults to None.

Returns:

Image model instance.

Return type:

ImageBase

Raises:
  • KeyError – If required keys are missing.

  • ValueError – If configuration values are invalid.

  • TypeError – If configuration values have incompatible types.

abstract property type: ImageType#

Return the image model type.

Returns:

Image type.

Return type:

ImageType

abstract property param_dict: dict#

Return image parameters as a dictionary.

The returned dictionary must be compatible with from_dict().

Returns:

Image parameters.

Return type:

dict

abstract property is_geo_referenced: bool#

Return whether the image is geo-referenced.

Returns:

True if geo-referenced (and mapping/projection can be computed), otherwise False.

Return type:

bool

abstract property center: tuple[float, float]#

Return the center of the image in pixel coordinates.

Implementations may define the center differently (e.g. the principal point for perspective cameras).

Returns:

Center point (x, y) in pixel coordinates.

Return type:

tuple[float, float]

abstractmethod position_to_crs(crs_t: CRS) Vector3D | None[source]#

Return the image reference position in the target CRS.

Parameters:

crs_t (CRS) – Target CRS.

Returns:

Position in crs_t or None if unavailable.

Return type:

Vector3D | None

Raises:

CoordinateTransformationError – If coordinate transformation fails.

abstractmethod project(coordinates: ArrayNx3, crs_s: CRS | None = None, transformer: CoordinateTransformer | None = None) ProjectionResultSuccess | ResultFailure[Issue][source]#

Project 3D coordinates into image pixel coordinates.

Parameters:
  • coordinates (ArrayNx3) – 3D coordinates to project.

  • crs_s (CRS | None) – CRS of the input coordinates, defaults to None.

  • transformer (CoordinateTransformer | None) – Optional coordinate transformer, defaults to None.

Returns:

Result of the projection.

Return type:

ProjectionResult

Raises:

CoordinateTransformationError – If coordinate transformation fails.

abstractmethod map_center_point(mapper: MappingBase | None = None, transformer: CoordinateTransformer | None = None) MappingResultSuccess | ResultFailure[Issue][source]#

Map the image center pixel to 3D coordinates.

For perspective images this is typically the principal point.

Parameters:
Returns:

Mapping result.

Return type:

MappingResult

Raises:

CoordinateTransformationError – If coordinate transformation fails.

abstractmethod map_footprint(points_per_edge: int = 0, mapper: MappingBase | None = None, transformer: CoordinateTransformer | None = None) MappingResultSuccess | ResultFailure[Issue][source]#

Map footprint of image to 3D.

Parameters:
  • points_per_edge (int) – The number of points inserted between corners, defaults to 0. 0 means only corner points are mapped.

  • mapper (MappingBase | None) – Mapper to use, defaults to None (uses mapper).

  • transformer (CoordinateTransformer | None) – Optional coordinate transformer, defaults to None.

Returns:

Mapping result.

Return type:

MappingResult

Raises:

CoordinateTransformationError – If coordinate transformation fails.

abstractmethod map_points(points_image: ArrayNx2 | ArrayNx3 | list[list[float]] | list[list[int]] | list[float] | list[int], mapper: MappingBase | None = None, transformer: CoordinateTransformer | None = None) MappingResultSuccess | ResultFailure[Issue][source]#

Map image pixel coordinates to 3D coordinates.

Parameters:
  • points_image (ArrayNx2 | ArrayNx3 | list[list[float]] | list[list[int]] | list[float] | list[int]) – Pixel coordinates.

  • mapper (MappingBase | None) – Mapper to use, defaults to None (uses mapper).

  • transformer (CoordinateTransformer | None) – Optional coordinate transformer, defaults to None.

Returns:

Mapping result.

Return type:

MappingResult

Raises:
property position_wgs84: tuple[float, float, float] | None#

4979) of the image or None if not possible. The position_to_crs method is defined by the class implementation.

Returns:

Position in WGS84 (x, y, z) or None.

Return type:

tuple[float, float, float] | None

Raises:

CoordinateTransformationError – If coordinate transformation fails.

Type:

Return the position in WGS84 (EPSG

property position_wgs84_geojson: dict | None#
  1. as a GeoJSON point.

Returns:

GeoJSON Point mapping or None if the position is unavailable.

Return type:

dict | None

Raises:

CoordinateTransformationError – If coordinate transformation fails.

Type:

Return the image position in WGS84 (EPSG

property crs: CRS | None#

Return the image world CRS.

Returns:

CRS of the image or None if unknown.

Return type:

CRS | None

property crs_wkt: str | None#

Return images CRS as wkt string

property crs_proj4: str | None#

Return images CRS as proj4 string

property width: int#

Return width of image (column number)

property height: int#

Return height of image (row number)

property shape: tuple[int, int]#

Return shape of image as tuple(width, height)