transform¶
- geodetic_engine.geodesy.transform(source_crs, target_crs, x, y=None, z=None, *, operation=None, allow_any_operation=False, coordinate_epoch=None)[source]¶
Transform points between two CRSs in one call.
A thin front for
Transformationfor the case where the transformation is used once. Resolved transformations are cached, so repeating the same call does not repeat the resolution. Prefer building aTransformationdirectly when transforming many separate batches.- Parameters:
source_crs (
Any) – CRS the input coordinates are in.target_crs (
Any) – CRS to produce coordinates in.x (
Iterable[Iterable[float]] |Iterable[float] |float) – Either every point’s values in one go – a single point given flat such as(lon, lat), a list of tuples, or a 2D numpy array of shape(n_points, n_axes)– whenyis omitted; or just the first axis’s values, matchingpyproj.Transformer.transform()’sxx, yy, zzconvention, whenyis given.y (
Iterable[float] |float|None, default:None) – Second axis’s values: a scalar for one point, or a sequence for a batch. Omit to passxas the whole set of points instead.z (
Iterable[float] |float|None, default:None) – Third axis’s values (for example a height), in the same shape asxandy. A lone scalar is broadcast against the other axes, so one height can be given once for many horizontal points rather than repeated.operation (
str|int|OperationCandidate|StatedOperation|CoordinateOperation|Sequence[str|int|OperationCandidate|StatedOperation|CoordinateOperation] |None, default:None) – EPSG coordinate operation to apply, for example"EPSG:15670", or anOperationCandidatefromavailable_operations(). Or several, when a compound target CRS needs more than one pinned down – order does not matter, seeTransformation. Or the operation itself, stated as an OSDU persistableReference payload, an ESRIGEOGTRAN, apyproj.crs.CoordinateOperationor a parsed reference, which is then applied as given rather than looked up. Required whenever a datum change is involved, except where a bound CRS already names it.allow_any_operation (
bool, default:False) – Compatibility keyword with no effect on strict datum-operation selection or ballpark refusal.coordinate_epoch (
float|None, default:None) – Decimal year the coordinates were observed at, required when the selected operation reads time. A dynamic CRS alone does not require an epoch.
- Return type:
- Returns:
The transformed coordinates and their provenance.
- Raises:
AmbiguousOperationError – If no operation was given, the transformation involves an unbound datum change.
Example
>>> result = transform( ... "EPSG:4258", "EPSG:25832", (10.75, 59.91), ... operation="EPSG:16032", ... ) >>> result.operation.authority_code 'EPSG:16032' >>> result.target_axes ('E', 'N')
Or as separate per-axis values:
>>> result = transform( ... "EPSG:4258", "EPSG:25832", 10.75, 59.91, operation="EPSG:16032" ... ) >>> result.coordinates ((597868.38..., 6642681.51...),)