Python API#

Array dispatch#

Transformer selects execution from the input arrays and the method called. A CUDA-capable build does not move a NumPy transform() call to the GPU.

Call and input

Execution

Result

transform() with NumPy arrays

Host

NumPy arrays

transform() with CuPy arrays

CUDA

CuPy arrays

transform_device() with host arrays

Stages inputs to CUDA and waits

CuPy arrays

enqueue_device()

CUDA submission that may copy inputs, pack validity, and allocate outputs or workspace

A CudaExecution handle

Mixing array types in a transform() call raises TypeError. On a CUDA-capable installation, the following checks make the return types visible.

import numpy as np
import cupy as cp
from cugeo.proj import Transformer

t = Transformer.from_crs(4326, 32631)
a = np.array([3.0], dtype=np.float64)
x, y = t.transform(a, a)
print(isinstance(x, np.ndarray), isinstance(y, np.ndarray))
x, y = t.transform_device(a, a)
print(isinstance(x, cp.ndarray), isinstance(y, cp.ndarray))

Both pairs of checks should be true. See the transformer declarations for the calls and their options.

Where are my coordinates and row diagnostics?#

A two-dimensional pair takes x and y. A three-dimensional pair also requires z. Synchronous calls return coordinates first, followed by status and then failure information when those diagnostics are selected. Host masks intersect explicit validity.

For enqueue_device(), request row causes with return_failures=True. Coordinate outputs are separate from CudaExecution.failures. Use the execution’s completion methods to obtain results. To decide whether a returned row is usable, see Errors and per-point statuses.

CRS inputs and metadata#

Input or requested output

Lookup

EPSG authority

Use the EPSG constructors. to_epsg() and to_authority() default to confidence 70.

WKT

Construct from WKT or use to_wkt(). The output default is WKT1_GDAL. WKT2_2015 and WKT2_2019 are available, with semantic-loss checks.

PROJ text or parameters

Construct from PROJ input or export legacy PROJ text. Legacy exports can lose axis or other metadata.

Mapping or PROJJSON

Construct from a mapping or PROJJSON. Legacy mapping exports can lose axis or other metadata.

Foreign CRS object

from_user_input() can obtain WKT through one to_wkt() call.

Caller-owned WKT buffer

to_wkt_into() requires a writable C-contiguous buffer. Its byte count includes the terminating NUL. A short buffer raises BufferError before any write.

CRS metadata exposes native axes, units, and component CRSs. Equality preserves declared axis order. CRS values are immutable and unhashable. Serialize method access when sharing a value. The CRS constructor refuses epoch-bearing WKT metadata, although operation resolution can handle epoch-qualified definitions. See the CRS declarations for conversions and metadata access.

Typed transformers and execution lifetime#

FrameTransformer handles typed three-ordinate frame composition. GeocentricTransformer supports host and device transformations. Height requirements depend on the profile, and promoted 2D profiles can supply zero height. HelmertTransformer selects a registered profile or CRS pair. Its parameter convention and static or dynamic coordinate-epoch admission depend on that profile. Typed Python Arrow Device entry points reject N-D layout. See the frame, geocentric, and Helmert declarations.

CudaExecution, FrameCudaExecution, GeocentricCudaExecution, and HelmertCudaExecution provide query, wait, and close. They retain data owners until native release succeeds. Borrowed handle calls can be concurrent. close is exclusive. If native release fails, retry the close. Retained references are dropped after release. See the execution declarations.

Device resources#

DeviceResource accepts allocation and deallocation callbacks and an explicit nondefault stream. It uses the current CUDA context by default. Allocated pointers must meet the required alignment, and the stream must be usable. A transformer, workspace, or shared grid retains the resource, and preparation waits on its stream. Deallocation must succeed without raising. An allocation callback’s MemoryError maps to OutOfMemoryError. Other allocation exceptions map to CudaError. See the DeviceResource declarations.

The generated signature index following this introduction covers the 33 public exports, including aliases, methods, defaults, and return types. The export list is defined in cugeo.proj.__all__.

Generated export index#

The index follows the literal public exports in the Python source. Function signatures preserve parameter names, defaults, and annotations. The binding column identifies re-exports and imported definitions. Runtime route conditions belong with each operation.

cugeo.proj#

Export

Declaration

Binding

AxisInfo

Class

cugeo.proj.crs.AxisInfo

CRS

Class

cugeo.proj.crs.CRS

CudaExecution

Class

cugeo.proj.execution.CudaExecution

CudaError

Class

cugeo.proj.errors.CudaError

CudaUnavailableError

Class

cugeo.proj.errors.CudaUnavailableError

CugeoProjError

Class

cugeo.proj.errors.CugeoProjError

BufferError

Class

cugeo.proj.errors.BufferError

CaptureError

Class

cugeo.proj.errors.CaptureError

DeviceResource

Class

cugeo.proj.device_resource.DeviceResource

FrameCudaExecution

Class

cugeo.proj.execution.FrameCudaExecution

FrameTransformer

Class

cugeo.proj.frame.FrameTransformer

GeocentricCudaExecution

Class

cugeo.proj.execution.GeocentricCudaExecution

GeocentricTransformer

Class

cugeo.proj.geocentric.GeocentricTransformer

HelmertCudaExecution

Class

cugeo.proj.execution.HelmertCudaExecution

HelmertTransformer

Class

cugeo.proj.helmert.HelmertTransformer

InternalError

Class

cugeo.proj.errors.InternalError

InvalidArgumentError

Class

cugeo.proj.errors.InvalidArgumentError

InvalidCrsError

Class

cugeo.proj.errors.InvalidCrsError

MissingResourceError

Class

cugeo.proj.errors.MissingResourceError

OutOfMemoryError

Class

cugeo.proj.errors.OutOfMemoryError

ProjError

Class

cugeo.proj.errors.ProjError

ProjVersionRequiredError

Class

cugeo.proj.errors.ProjVersionRequiredError

ResourceLimitError

Class

cugeo.proj.errors.ResourceLimitError

Resolution

Class

cugeo.proj.resolution.Resolution

RowFailure

Class

cugeo.proj._ffi.structures.RowFailure

RowStatus

Class

cugeo.proj._ffi.structures.RowStatus

Transformer

Class

cugeo.proj.transformer.Transformer

UnsupportedError

Class

cugeo.proj.errors.UnsupportedError

WorkspaceBusyError

Class

cugeo.proj.errors.WorkspaceBusyError

__version__

Attribute

cugeo.proj._core.__version__

built_with_cuda

built_with_cuda() -> bool

cugeo.proj._ffi.library.built_with_cuda

capabilities

capabilities() -> dict[str, Any]

cugeo.proj._ffi.library.capabilities

native_library_path

native_library_path() -> pathlib.Path

cugeo.proj._ffi.library.native_library_path

Generated direct class declarations#

These entries list public methods declared on the class. Source signatures may show a receiver parameter. Inherited methods and generated constructors follow the class or external binding named in the export index.

cugeo.proj.CRS#

  • __init__(self, initialdata=None, **kwargs)

  • from_epsg(cls, code)

  • from_authority(cls, auth_name, code)

  • from_wkt(cls, wkt)

  • from_proj4(cls, text)

  • from_dict(cls, initialdata=None, **kwargs)

  • from_string(cls, text)

  • from_user_input(cls, value, *, memory_budget_bytes=None, retained_input_bytes=0)

  • memory_info — property

  • name — property

  • type_name — property

  • axis_info — property

  • is_geographic — property

  • is_projected — property

  • linear_units — property

  • linear_units_factor — property

  • units_factor — property

  • sub_crs_list — property

  • source_crs — property

  • target_crs — property

  • to_authority(self, confidence_threshold=70)

  • to_epsg(self, confidence_threshold=70)

  • to_wkt(self, version=None)

  • to_wkt_into(self, buffer=None, *, version=None) -> int

  • wkt — property

  • to_dict(self, projjson=False)

  • to_proj4(self)

  • to_string(self)

  • equals(self, other)

  • runtime_info(self)

cugeo.proj.CudaExecution#

  • __init__(self, handle: ct.c_void_p, owners: Iterable[Any], result: tuple[Any, ...], transformer: Any, *, failures: Any \| None, route: bool=False) -> None

  • failures(self) -> Any

cugeo.proj.DeviceResource#

  • __init__(self, allocate: Callable[[int, int, int], int], deallocate: Callable[[int, int, int, int], Any], *, stream: Any, context: int \| None=None)

  • close(self) -> None

cugeo.proj.FrameCudaExecution#

  • __init__(self, handle: ct.c_void_p, owners: Iterable[Any], result: tuple[Any, ...], transformer: Any) -> None

cugeo.proj.FrameTransformer#

  • __init__(self, source: str \| int, target: str \| int, *, device_resource: DeviceResource \| None=None)

  • from_crs(cls, source: str \| int, target: str \| int, *, device_resource: DeviceResource \| None=None) -> 'FrameTransformer'

  • explain(self) -> dict[str, Any]

  • transform_device(self, x: Any, y: Any, z: Any, *, validity: Any \| None=None, stream: Any \| None=None) -> FrameCudaExecution

  • transform_arrow_device(self, *_args: Any, **_kwargs: Any) -> Any

  • close(self) -> None

cugeo.proj.GeocentricCudaExecution#

  • __init__(self, handle: ct.c_void_p, owners: Iterable[Any], result: tuple[Any, ...], transformer: Any) -> None

cugeo.proj.GeocentricTransformer#

  • __init__(self, source: str \| int, target: str \| int, *, device_resource: DeviceResource \| None=None)

  • from_crs(cls, source: str \| int, target: str \| int, *, device_resource: DeviceResource \| None=None) -> 'GeocentricTransformer'

  • explain(self) -> dict[str, Any]

  • prepared_explain(self) -> dict[str, Any]

  • transform(self, x: Any, y: Any, z: Any \| None=None, *, validity: Any \| None=None, return_status: bool=False, stream: Any \| None=None) -> tuple[Any, ...]

  • transform_device(self, x: Any, y: Any, z: Any \| None=None, *, validity: Any \| None=None, stream: Any \| None=None) -> GeocentricCudaExecution

  • transform_arrow_device(self, *_args: Any, **_kwargs: Any) -> Any

  • close(self) -> None

cugeo.proj.HelmertCudaExecution#

  • __init__(self, handle: ct.c_void_p, owners: Iterable[Any], result: tuple[Any, ...], prepared: ct.c_void_p, workspace: ct.c_void_p) -> None

cugeo.proj.HelmertTransformer#

  • __init__(self, profile: str, *, direction: str='forward', coordinate_epoch: float \| None=None, per_row_epoch: bool=False)

  • from_profile(cls, profile: str, **kwargs: Any) -> 'HelmertTransformer'

  • from_crs(cls, source: str \| int, target: str \| int, **kwargs: Any) -> 'HelmertTransformer'

  • explain(self) -> dict[str, Any]

  • transform_device(self, longitude: Any, latitude: Any, height: Any, *, epoch: Any \| None=None, validity: Any \| None=None, stream: Any \| None=None, fixed_q62: bool=False) -> HelmertCudaExecution

  • transform_arrow_device(self, *_args: Any, **_kwargs: Any) -> Any

cugeo.proj.Resolution#

  • __init__(self, handle: ct.c_void_p)

  • resolve(cls, source: str \| int \| CRS, target: str \| int \| CRS, *, area_of_interest: tuple[float, float, float, float] \| None=None, resource_directory: str \| os.PathLike[str] \| None=None, operation: str \| dict[str, Any] \| None=None, epoch: float \| None=None, reference_epoch: bool=False) -> 'Resolution'

  • from_record(cls, record: str \| dict[str, Any], *, resource_directory: str \| os.PathLike[str] \| None=None) -> 'Resolution'

  • explain(self) -> dict[str, Any]

  • record(self) -> dict[str, Any]

  • close(self) -> None

cugeo.proj.Transformer#

  • __init__(self, source: str \| int \| CRS, target: str \| int \| CRS, *, always_xy: bool=True, area_of_interest: tuple[float, float, float, float] \| None=None, resource_directory: str \| os.PathLike[str] \| None=None, operation: str \| dict[str, Any] \| None=None, epoch: float \| None=None, reference_epoch: bool=False, device_resource: DeviceResource \| None=None)

  • from_crs(cls, source: str \| int \| CRS, target: str \| int \| CRS, *, always_xy: bool=True, area_of_interest: tuple[float, float, float, float] \| None=None, resource_directory: str \| os.PathLike[str] \| None=None, operation: str \| dict[str, Any] \| None=None, epoch: float \| None=None, reference_epoch: bool=False, device_resource: DeviceResource \| None=None) -> 'Transformer'

  • from_resolution(cls, resolution: Resolution, *, always_xy: bool=True, device_resource: DeviceResource \| None=None) -> 'Transformer'

  • from_record(cls, record: str \| dict[str, Any], *, resource_directory: str \| os.PathLike[str] \| None=None, always_xy: bool \| None=None, device_resource: DeviceResource \| None=None) -> 'Transformer'

  • dimensions — property

  • explain(self) -> dict[str, Any]

  • prepared_explain(self) -> dict[str, Any]

  • to_record(self) -> dict[str, Any]

  • transform(self, x: Any, y: Any, z: Any \| None=None, *, validity: Any \| None=None, return_status: bool=False, return_failures: bool=False, stream: Any \| None=None) -> tuple[Any, ...]

  • transform_device(self, x: Any, y: Any, z: Any \| None=None, *, validity: Any \| None=None, return_status: bool=False, return_failures: bool=False, stream: Any \| None=None) -> tuple[Any, ...]

  • enqueue_device(self, x: Any, y: Any, z: Any \| None=None, *, validity: Any \| None=None, stream: Any \| None=None, return_failures: bool=False) -> CudaExecution

  • close(self) -> None