healpix_geo.cartesian_to_lonlat#

healpix_geo.cartesian_to_lonlat(x, y, z, ellipsoid='sphere', num_threads=0)#

Convert cartesian coordinates to geographic coordinates on the surface of the ellipsoid.

This drops the height coordinate, resulting in a lossy conversion for coordinates that are not on the surface.

Parameters:
  • x, y, z (numpy.ndarray) – The cartesian coordinates in meters. All arrays must have the exactly same shape (no broadcasting).

  • ellipsoid (ellipsoid-like, default: "sphere") – The ellipsoid to evaluate the coordinates on.

  • num_threads (int, optional) – Specifies the number of threads to use for the computation. Default to 0 means it will choose the number of threads based on the RAYON_NUM_THREADS environment variable (if set), or the number of logical CPUs (otherwise)

Returns:

lon, lat (numpy.ndarray) – The equivalent geographic coordinates.

Examples

>>> from healpix_geo import cartesian_to_lonlat
>>> import numpy as np
>>> x = np.array([4728734.69011096, 3814362.85063174, 5302653.40426395])
>>> y = np.array([465739.71573273, 4647814.58136658, 2834327.29466645])
>>> z = np.array([4240471.60205904, 2121029.89621885, 2121029.89621885])
>>> lon, lat = cartesian_to_lonlat(x, y, z, ellipsoid="WGS84")
>>> lon
array([ 5.625, 50.625, 28.125])
>>> lat
array([41.93785391, 19.55202227, 19.55202227])