Project survey points onto a UTM map#
cuGeo helps GIS developers run vector analysis, raster processing, and coordinate transformations on NVIDIA GPUs, accelerating analytics and making new analytics possible at larger world-scale. In this lesson, you’ll project two survey points into the map coordinates of an EPSG:32631 imagery layer, ready to plot them on that layer.
Predict the first map position#
The inputs are float64 WGS 84 longitude [3.0, 6.0] and latitude [0.0, 45.0], in degrees. The example creates a transformer with Transformer.from_crs(4326, 32631, always_xy=True): always_xy=True means you supply longitude first and latitude second.
The first point is at 3°E on the equator. Expect an easting of 500,000 m and a northing of 0 m. The second point is farther east and north.
Project both points#
Use a CUDA-enabled Python environment with cuGeo Proj, matching CuPy, NumPy, and pyproj installed. If you need to choose the CuPy extra and native CUDA build, see Install Proj for your CUDA version.
From the repository root, run the example with the selected Python environment active.
python -I cugeo-proj/examples/device.py
The script uses a nondefault stream to copy both arrays to the GPU. It waits for the result, then copies the coordinates and statuses back for checking.
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
import cupy as cp
import numpy as np
import pyproj
from cugeo.proj import RowStatus, Transformer
longitude = np.asarray([3.0, 6.0], dtype=np.float64)
latitude = np.asarray([0.0, 45.0], dtype=np.float64)
reference = pyproj.Transformer.from_crs(4326, 32631, always_xy=True)
expected_easting, expected_northing = reference.transform(
longitude, latitude, errcheck=True
)
stream = cp.cuda.Stream(non_blocking=True)
with Transformer.from_crs(4326, 32631, always_xy=True) as transformer:
with stream:
device_longitude = cp.asarray(longitude)
device_latitude = cp.asarray(latitude)
easting, northing, status = transformer.transform_device(
device_longitude, device_latitude, return_status=True, stream=stream
)
easting, northing, status = map(cp.asnumpy, (easting, northing, status))
np.testing.assert_array_equal(status, [RowStatus.OK, RowStatus.OK])
error_metres = np.hypot(easting - expected_easting, northing - expected_northing)
assert np.all(np.isfinite(error_metres)) and np.all(error_metres <= 1e-6), error_metres
print("easting (m):", easting)
print("northing (m):", northing)
print("status:", [RowStatus(int(value)).name for value in status])
print(f"Checked against pyproj PROJ {pyproj.proj_version_str}: max error <= 1e-6 m")
Read the two positions#
The coordinate lines are approximate. The last line also reports pyproj’s PROJ version.
easting (m): [500000. 736446.02610121]
northing (m): [ 0. 4987329.50469891]
status: ['OK', 'OK']
Checked against pyproj PROJ 9.8.1: max error <= 1e-6 m
Read the easting, northing, and status at the same index. The first pair matches the prediction, and the second is about 736,446 m easting and 4,987,330 m northing. For each point, the file checks that the status is OK and that the distance from the pyproj position is finite and at most 1e-6 m. You now have two checked positions to plot on the UTM layer.