MappingTrimesh#

For deeper information about the concept see: Mesh Mapper

Class Methods

MappingTrimesh.from_dict(mapper_dict)

Create a MappingTrimesh instance from a configuration dictionary.

Main API Methods

MappingTrimesh.map_coordinates_from_rays(...)

Map coordinates by intersecting rays with the mesh surface.

MappingTrimesh.map_heights_from_coordinates(...)

Sample heights by casting vertical rays against the mesh.

Properties

MappingTrimesh.type

Return the mapper type.

MappingTrimesh.param_dict

Return the mapper configuration dictionary.

MappingTrimesh.crs

Return the CRS of the mapper (if set).

MappingTrimesh.crs_wkt

Return the CRS as WKT string, or None if not set.

class weitsicht.MappingTrimesh(mesh_path: Path | str, crs: CRS | None = None, coordinate_shift: Vector3D | None = None)[source]#

Bases: MappingBase

Mapping backend that intersects rays with a mesh surface.

Parameters:
  • mesh_path (Path | str)

  • crs (CRS | None)

  • coordinate_shift (Vector3D | None)

__init__(mesh_path: Path | str, crs: CRS | None = None, coordinate_shift: Vector3D | None = None)[source]#

Create a mesh-based mapper.

Parameters:
  • mesh_path (Path | str) – Path to the mesh file.

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

  • coordinate_shift (Vector3D | None) – Optional translation applied to the mesh coordinates, defaults to None.

Raises:
  • FileNotFoundError – If mesh_path does not exist.

  • CRSnoZaxisError – If a specified CRS does not define a Z axis.

  • MappingError – If the mesh is empty or the file format is unsupported.

property type#

Return the mapper type.

classmethod from_dict(mapper_dict: Mapping[str, Any]) MappingTrimesh[source]#

Create a MappingTrimesh instance from a configuration dictionary.

Required keys: - type: must be Trimesh - mesh_filepath: file path to the mesh

Optional keys: - crs: CRS WKT string, defaults to None - coordinate_shift: translation vector, defaults to None

Parameters:

mapper_dict (Mapping[str, Any]) – Mapper configuration dictionary (typically created via mapper.param_dict).

Returns:

Instantiated mapper.

Return type:

MappingTrimesh

Raises:
  • KeyError – If a required dictionary key is missing.

  • ValueError – If the mapper type is unsupported.

  • CRSInputError – If the CRS WKT string is invalid.

property param_dict#

Return the mapper configuration dictionary.

Returns:

Mapper configuration dictionary.

Return type:

dict[str, Any]

map_coordinates_from_rays(ray_vectors_crs_s: ArrayNx3, ray_start_crs_s: ArrayNx3, crs_s: CRS | None = None, transformer: CoordinateTransformer | None = None) MappingResultSuccess | ResultFailure[Issue][source]#

Map coordinates by intersecting rays with the mesh surface.

Parameters:
  • ray_vectors_crs_s (ArrayNx3) – Ray direction vectors (N×3).

  • ray_start_crs_s (ArrayNx3) – Ray start points (N×3), same shape as ray_vectors_crs_s.

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

  • transformer (CoordinateTransformer | None) – Coordinate transformer to mapper CRS, defaults to None.

Returns:

Mapping result containing intersection coordinates and a validity mask.

Return type:

MappingResult

Raises:
map_heights_from_coordinates(coordinates_crs_s: ArrayNx3 | ArrayNx2, crs_s: CRS | None = None, transformer: CoordinateTransformer | None = None) MappingResultSuccess | ResultFailure[Issue][source]#

Sample heights by casting vertical rays against the mesh. Vertical in the sense of vertical in the mapper crs

Parameters:
  • coordinates_crs_s (ArrayNx3 | ArrayNx2) – Coordinates to sample (N×2 or N×3).

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

  • transformer (CoordinateTransformer | None) – Coordinate transformer to mapper CRS, defaults to None.

Returns:

Mapping result containing sampled coordinates and a validity mask.

Return type:

MappingResult

Raises: