TransformationResult

class geodetic_engine.geodesy.TransformationResult[source]

Bases: object

Transformed coordinates together with everything that produced them.

coordinates

One tuple per point, holding that point’s values in xy order in the units of the target CRS’s axes. There is one value per axis the target CRS declares, so a vertical target yields one value per point even though PROJ computes three. If the input carried one value more than the source CRS declares – a height alongside a 2D horizontal CRS – that value is carried through unchanged as one extra trailing component, so coordinates can then hold one more value per point than target_axes lists. Behaves as a plain tuple of tuples (indexing, iteration, equality), with Coordinates.to_list(), to_numpy() and to_dataframe() for exporting it in a specific format.

source_crs

CRS the input was expressed in.

target_crs

CRS the output is expressed in.

operation

Which coordinate operation was applied, and how it was arrived at.

grids

Grid files the operation depended on.

coordinate_epoch

Decimal year supplied with the input, if any.

coordinate_order

Order the values in coordinates are in. Always "xy": easting or longitude first wherever the target CRS has an easting and a northing to order, whatever order it declares them in. A CRS with no such pair – Krovak’s southing and westing, a geocentric X/Y/Z, a plant grid with a north and a west axis – is left in its declared order, exactly as PROJ’s always_xy leaves it; value_axis_order on target_crs states the resulting order axis by axis. Present so that a caller reading target_axes as ("Lat", "Lon") cannot mistake the declared axis order for the value order.

pipeline

The whole chain as one PROJ pipeline definition, ready to be rebuilt with pyproj.Transformer.from_pipeline(), or None when it cannot be written as a single pipeline. It reads the values the caller gave, in this package’s xy order, and writes the values returned in coordinates, so replaying it reproduces the result – with one exception: at a vertical target it writes PROJ’s own three components, of which coordinates keeps only the height.

database_fingerprints

Paths and SHA-256 hashes of databases present when the transformation was resolved, retained across later calls.

Example

>>> from geodetic_engine.geodesy import transform
>>> result = transform(
...     "EPSG:4230", "EPSG:4326", (2.5, 63.5), operation="EPSG:1612"
... )
>>> result.target_axes
('Lat', 'Lon')
>>> result.coordinate_order
'xy'
>>> result.coordinates[0]
(2.49818..., 63.49961...)

The axes are declared latitude first, the values are longitude first.

property count: int

How many points the result holds.

property source_axes: tuple[str, ...]

Source CRS axis abbreviations, in EPSG-declared order.

property target_axes: tuple[str, ...]

Target CRS axis abbreviations, in EPSG-declared order.

property source_units: tuple[str, ...]

Source CRS axis units, in EPSG-declared order.

property target_units: tuple[str, ...]

Target CRS axis units, in EPSG-declared order.

property missing_grids: tuple[str, ...]

Names of grids the operation needs that are not installed.

Always empty on a returned result, since a missing grid raises. Kept so that a caller logging a result does not have to special-case it.

to_json_dict()[source]

Render the result as plain data, for logging or serialisation.

Return type:

dict[str, Any]

Returns:

A dict carrying the coordinates and every provenance field.

Example

>>> from geodetic_engine.geodesy import transform
>>> transform(
...     "EPSG:4230", "EPSG:4326", (2.5, 63.5), operation="EPSG:1612"
... ).to_json_dict()["coordinates"]
[[2.49818..., 63.49961...]]
to_json(*, pretty=True)[source]

Serialise the result as JSON.

Parameters:

pretty (bool, default: True) – Whether to indent the output over several lines. True by default, since this is meant for a human to read; pass False for a compact form to log or send over the wire.

Return type:

str

Returns:

The same fields as to_json_dict(), as a JSON string.

Example

>>> print(result.to_json(pretty=False))
{"coordinates": [[10.7522, 59.9139]], ...}
__init__(coordinates, source_crs, target_crs, operation, grids, coordinate_epoch, coordinate_order='xy', pipeline=None, database_fingerprints=())