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 |
|---|---|---|
|
Host |
NumPy arrays |
|
CUDA |
CuPy arrays |
|
Stages inputs to CUDA and waits |
CuPy arrays |
|
CUDA submission that may copy inputs, pack validity, and allocate outputs or workspace |
A |
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. |
WKT |
Construct from WKT or use |
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 |
|
Caller-owned WKT buffer |
|
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 |
|---|---|---|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Class |
|
|
Attribute |
|
|
|
|
|
|
|
|
|
|
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 — propertyname — propertytype_name — propertyaxis_info — propertyis_geographic — propertyis_projected — propertylinear_units — propertylinear_units_factor — propertyunits_factor — propertysub_crs_list — propertysource_crs — propertytarget_crs — propertyto_authority(self, confidence_threshold=70)to_epsg(self, confidence_threshold=70)to_wkt(self, version=None)to_wkt_into(self, buffer=None, *, version=None) -> intwkt — propertyto_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) -> Nonefailures(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) -> FrameCudaExecutiontransform_arrow_device(self, *_args: Any, **_kwargs: Any) -> Anyclose(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) -> GeocentricCudaExecutiontransform_arrow_device(self, *_args: Any, **_kwargs: Any) -> Anyclose(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) -> HelmertCudaExecutiontransform_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 — propertyexplain(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) -> CudaExecutionclose(self) -> None