Keep track of points outside a projection’s domain#

Transform a batch into Web Mercator coordinates while keeping the identity and outcome of every point. You’ll get one position to plot and a record of why each of the other two was rejected.

Keep an ID beside each input point#

In a CUDA-enabled cuGeo Proj Python environment, create these arrays on the default CuPy stream. The IDs stay on the host in the same order as the WGS 84 longitudes and latitudes, which are in degrees.

import numpy as np
import cupy as cp
from cugeo.proj import Transformer, RowStatus, RowFailure

ids = np.array(['A', 'B', 'C'])
lon = cp.array([3.0, 1.0, 1.0], dtype=cp.float64)
lat = cp.array([50.0, 89.5, 90.1], dtype=cp.float64)

Request an outcome for every point#

Request both status and failure arrays. Status identifies coordinates to keep, and the optional failure value identifies the check that failed. Once the call returns, copy all four arrays to the host for reporting.

t = Transformer.from_crs(4326, 3857, always_xy=True)
x, y, status, failure = t.transform_device(
    lon, lat, return_status=True, return_failures=True
)
x, y, status, failure = map(cp.asnumpy, (x, y, status, failure))