Transformer#
the cuproj.transformer module contains the Transformer class, which can perform 2D transformations between coordinate reference systems (CRS).
- class cuproj.transformer.Transformer(crs_from, crs_to)#
Bases:
object
A transformer object to transform coordinates from one CRS to another.
Notes
Currently only the EPSG authority is supported. Currently only projection from WGS84 to UTM (and vice versa) is supported.
Examples
>>> from cuproj import Transformer >>> transformer = Transformer.from_crs("epsg:4326", "epsg:32631") >>> transformer.transform(2, 49) (500000.0, 5460836.5) >>> transformer.transform(500000, 5460836.5, direction="INVERSE") (2.0, 49.0)
Methods
from_crs
(crs_from, crs_to)Create a transformer from a source CRS to a target CRS.
transform
(x, y[, direction])Transform coordinates from one CRS to another.
- static from_crs(crs_from, crs_to)#
Create a transformer from a source CRS to a target CRS.
- Parameters
- crs_fromCRS
The source CRS.
- crs_toCRS
The target CRS.
- Source and target CRS may be:
- - An authority string [i.e. ‘epsg:4326’]
- - An EPSG integer code [i.e. 4326]
- - A tuple of (“auth_name”: “auth_code”) [i.e (‘epsg’, ‘4326’)]
- Returns
- Transformer
A transformer object to transform coordinates from one CRS to another.
Notes
Currently only the EPSG authority is supported.
- transform(x, y, direction='FORWARD')#
Transform coordinates from one CRS to another.
If the input data is already in device memory, and the input implements __cuda_array_interface__ , the data will be used directly. If the data is in host memory, it will be copied to the device.
- Parameters
- xfloat or array_like
The x coordinate(s) to transform.
- yfloat or array_like
The y coordinate(s) to transform.
- directionstr, optional
The direction of the transformation. Either “FORWARD” or “INVERSE”. Default is “FORWARD”.
- Returns
- tuple
A tuple of transformed x and y coordinates as cupy (device) arrays.