clouddrift.sphere.sphere_to_plane

clouddrift.sphere.sphere_to_plane#

clouddrift.sphere.sphere_to_plane(lon: ndarray, lat: ndarray, lon_origin: float = 0, lat_origin: float = 0) tuple[ndarray, ndarray][source]#

Convert spherical coordinates to a tangent (Cartesian) plane.

The arrays of input longitudes and latitudes are assumed to be following a contiguous trajectory. The Cartesian coordinate of each successive point is determined by following a great circle path from the previous point. The Cartesian coordinate of the first point is determined by following a great circle path from the origin, by default (0, 0).

The output arrays have the same floating-point output type as the input.

If projecting multiple trajectories onto the same plane, use apply_ragged() for highest accuracy.

Parameters#

lonnp.ndarray

An N-d array of longitudes in degrees

latnp.ndarray

An N-d array of latitudes in degrees

lon_originfloat, optional

Origin longitude of the tangent plane in degrees, default 0

lat_originfloat, optional

Origin latitude of the tangent plane in degrees, default 0

Returns#

xnp.ndarray

x-coordinates on the tangent plane

ynp.ndarray

y-coordinates on the tangent plane

Examples#

>>> sphere_to_plane(np.array([0., 1.]), np.array([0., 0.]))
(array([     0.        , 111318.84502145]), array([0., 0.]))

You can also specify an origin longitude and latitude:

>>> sphere_to_plane(np.array([0., 1.]), np.array([0., 0.]), lon_origin=1, lat_origin=0)
(array([-111318.84502145,       0.        ]),
 array([1.36326267e-11, 1.36326267e-11]))

Raises#

AttributeError

If lon and lat are not NumPy arrays

See Also#

plane_to_sphere()