Ellipsoids basics#

This tutorial explain why and how to use ellipsoids of reference in healpix-geo.

Supported Ellipsoids#

import numpy as np
from healpix_geo.nested import lonlat_to_healpix

# Test Point
lon, lat = np.array([0.0]), np.array([45.0])
depth = 10

ellipsoids = {
    "sphere": "Unit sphere",
    "WGS84": "Global geodetic standard",
    "GRS80": "Geodetic Reference System 1980",
    "WGS72": "World Geodetic System 1972",
}


print(f"HEALPix cell at point (0°, 45°) at depth={depth}:\n")
for ellipsoid, description in ellipsoids.items():
    ipix = lonlat_to_healpix(lon, lat, depth, ellipsoid=ellipsoid)
    print(f"{ellipsoid:10s}: {ipix[0]:10d}  # {description}")
HEALPix cell at point (0°, 45°) at depth=10:

sphere    :     703146  # Unit sphere
WGS84     :     700411  # Global geodetic standard
GRS80     :     700411  # Geodetic Reference System 1980
WGS72     :     700411  # World Geodetic System 1972

See also

For a list of supported named ellipsoids, see here.

Instead of using a predefined ellipsoid name, you can define a custom ellipsoid by explicitly providing its geometric parameters:

ipix = lonlat_to_healpix(lon, lat, depth, ellipsoid={"radius": 6371000.0})
ipix = lonlat_to_healpix(
    lon,
    lat,
    depth,
    ellipsoid={"semimajor_axis": 6378132.0, "inverse_flattening": 300.0},
)

The dictionary must contain either:

  • "radius" for a spherical model, or

  • "semimajor_axis" and "inverse_flattening" for an ellipsoidal model.

Which ellipsoid choose ?#

Tip

For most real-world geospatial applications, use WGS84, as it is the current global geodetic standard. Use a spherical model (sphere) only when high accuracy is not required.

Typical use case#

GPS data#

import numpy as np
from healpix_geo.nested import lonlat_to_healpix

# GPS trajectory data
gps_points = np.array(
    [
        [2.3522, 48.8566],  # Paris
        [2.3532, 48.8576],  # 100m further
        [2.3542, 48.8586],  # 100m further
    ]
)

lon_gps = gps_points[:, 0]
lat_gps = gps_points[:, 1]
depth = 29  # Highest resolution

# Always use WGS84 for GPS
ipix = lonlat_to_healpix(lon_gps, lat_gps, depth, ellipsoid="WGS84")
print(f"HEALPix cells of GPS trajectory:")
print(ipix)
HEALPix cells of GPS trajectory:
[196787752333180240 196787752498919375 196787753263527787]

Tip

For more information see HEALPix Extension to Ellipsoids

Next steps#

Reference systems
Reference system
Advanced conversion
Advanced coordinate conversion
Cover Requests
Cover requests