MappingGeorefArray#
For deeper information about the concept see: GeorefArray Mapper
Class Methods
|
Create a mapper from a configuration dictionary. |
Main API Methods
Map coordinates by intersecting rays with the raster surface. |
|
Sample heights for given coordinates using bilinear interpolation. |
Methods Raster specific
This functions can be used to interact with the raster and coordinates
Convert pixel indices to coordinates in raster CRS. |
|
|
Vectorized validity check for pixel coordinates. |
Test if given coordinates in raster CRS are on the raster |
|
Convert raster CRS coordinates to pixel indices. |
Properties
Return the mapper type. |
|
Return the mapper configuration dictionary. |
|
|
Return the CRS of the mapper (if set). |
|
Return the CRS as WKT string, or |
Return the affine geo-transform. |
|
Return raster width in pixels. |
|
Return raster height in pixels. |
- class weitsicht.MappingGeorefArray(raster_array: ndarray[tuple[Any, ...], dtype[_ScalarT]], geo_transform: Affine, crs: CRS | None)[source]#
Bases:
MappingBaseMapping backend using an in-memory geo-referenced raster array.
This backend is typically used internally (e.g. for raster window caching) and supports height sampling and ray intersections using bilinear patches.
- Parameters:
raster_array (ArrayNxN)
geo_transform (Affine)
crs (CRS | None)
- __init__(raster_array: ndarray[tuple[Any, ...], dtype[_ScalarT]], geo_transform: Affine, crs: CRS | None)[source]#
Create a mapper backed by a numpy array and an affine geo-transform.
- Parameters:
raster_array (ArrayNxN) – Raster data array (rows × cols) holding height values.
geo_transform (Affine) – Affine transformation mapping pixel indices to raster CRS coordinates.
crs (CRS | None) – CRS of the raster array, defaults to
None.
- Raises:
CRSnoZaxisError – If a specified CRS does not define a Z axis.
- property transform#
Return the affine geo-transform.
- Returns:
Affine geo-transform.
- Return type:
Affine
- property width#
Return raster width in pixels.
- property height#
Return raster height in pixels.
- classmethod from_dict(mapper_dict: Mapping[str, Any]) MappingGeorefArray[source]#
Create a mapper from a configuration dictionary.
This is currently not supported for
MappingGeorefArray.- Raises:
NotImplementedError – Always raised.
- Parameters:
mapper_dict (Mapping[str, Any])
- Return type:
- property type: MappingType#
Return the mapper type.
- property param_dict: dict#
Return the mapper configuration dictionary.
This is currently not supported for
MappingGeorefArray.- Raises:
NotImplementedError – Always raised.
- pixel_to_coordinate(px_row: ArrayN_, px_col: ArrayN_) tuple[source]#
Convert pixel indices to coordinates in raster CRS.
- Parameters:
px_row (
ArrayN_) – Pixel row coordinatepx_col (
ArrayN_) – Pixel column coordinate
- Returns:
(x, y)coordinates in raster CRS.- Return type:
tuple[
ArrayN_,ArrayN_]
- coordinate_to_pixel(x: ArrayN_, y: ArrayN_) tuple[ArrayN_, ArrayN_][source]#
Convert raster CRS coordinates to pixel indices.
- Parameters:
x (
ArrayN_) – X coordinate in raster CRS.y (
ArrayN_) – Y coordinate in raster CRS.
- Returns:
(row, col)pixel coordinates.- Return type:
tuple[
ArrayN_,ArrayN_]
- pixel_valid(px_row: ArrayN_, px_col: ArrayN_) MaskN_[source]#
Vectorized validity check for pixel coordinates.
- Parameters:
px_row (
ArrayN_) – Pixel row coordinatepx_col (
ArrayN_) – Pixel column coordinate
- Returns:
Boolean mask for valid pixels.
- Return type:
MaskN_
- pixel_valid_index_ray_bilinear_shifted(px_row: ArrayN_, px_col: ArrayN_) ndarray[source]#
Return indices of pixels valid for bilinear ray intersection.
This check assumes pixel coordinates are already shifted by
0.5. Border pixels are excluded because bilinear patches require 4 surrounding corner points.- Parameters:
px_row (
ArrayN_) – Pixel row coordinate already shifted by 0.5px_col (
ArrayN_) – Pixel column coordinate already shifted by 0.5
- Returns:
Indices of valid pixels.
- Return type:
numpy.ndarray
- coordinate_on_raster(x_crs: ArrayN_, y_crs: ArrayN_) bool[source]#
Test if given coordinates in raster CRS are on the raster
- Parameters:
x_crs (
ArrayN_) – X coordinatey_crs (
ArrayN_) – Y coordinate
- Returns:
Trueif all coordinates are within raster bounds.- Return type:
bool
- map_coordinates_from_rays_old_sampling(ray_vectors_crs_s: ArrayNx3, ray_start_crs_s: ArrayNx3, crs_s: CRS) ArrayNx3 | None[source]#
Legacy ray intersection method using dense sampling (deprecated).
- Parameters:
ray_vectors_crs_s (ArrayNx3) – Ray direction vectors (N×3).
ray_start_crs_s (ArrayNx3) – Ray start points (N×3).
crs_s (CRS) – CRS of the input rays.
- Returns:
Intersection coordinates or
Noneif no intersection was found.- Return type:
ArrayNx3 | None
- Raises:
CoordinateTransformationError – If coordinate transformation fails.
- 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 raster 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:
ValueError – If input arrays have incompatible shapes.
CRSInputError – If both
crs_sandtransformerare provided.CoordinateTransformationError – If coordinate transformation fails.
- map_heights_from_coordinates(coordinates_crs_s: ArrayNx3 | ArrayNx2, crs_s: CRS | None = None, transformer: CoordinateTransformer | None = None) MappingResultSuccess | ResultFailure[Issue][source]#
Sample heights for given coordinates using bilinear interpolation.
- 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:
CRSInputError – If both
crs_sandtransformerare provided.CoordinateTransformationError – If coordinate transformation fails.