Skip to content

Geodetic and Geocentric Coordinates

Functions for converting between geodetic, geocentric, and ECEF coordinates.

Geodetic Conversions

position_geodetic_to_ecef builtin

position_geodetic_to_ecef(x_geod: Union[ndarray, Sequence], angle_format: AngleFormat, axis: int = -1) -> ndarray

Convert geodetic position to ECEF Cartesian coordinates.

Transforms a position from geodetic coordinates (longitude, latitude, altitude) using the WGS84 ellipsoid model to Earth-Centered Earth-Fixed (ECEF) Cartesian coordinates.

Parameters:

Name Type Description Default
x_geod ndarray or list

Geodetic position [longitude, latitude, altitude] where longitude is in radians or degrees, latitude is in radians or degrees, and altitude is in meters above the WGS84 ellipsoid. Also accepts a batch of vectors with the 3 components along axis (for example shape (n, 3)).

required
angle_format AngleFormat

Angle format for input angular coordinates (RADIANS or DEGREES).

required
axis int

The axis of x_geod along which the 3 components of a single vector lie; the remaining axes enumerate the batch. For a batch of shape (n, 3) the components lie along the last axis, so the default -1 applies; a (3, n) column layout uses axis=0.

-1

Returns:

Type Description
ndarray

numpy.ndarray: ECEF Cartesian position [x, y, z] in meters. For batched input the output takes the batch layout of x_geod.

Example
1
2
3
4
5
6
7
8
import brahe as bh
import numpy as np

# Convert geodetic coordinates (GPS-like) to ECEF
lon, lat, alt = -105.0, 40.0, 1655.0  # Boulder, CO (degrees, meters)
x_geod = np.array([lon, lat, alt])
x_ecef = bh.position_geodetic_to_ecef(x_geod, bh.AngleFormat.DEGREES)
print(f"ECEF position: {x_ecef}")

position_ecef_to_geodetic builtin

position_ecef_to_geodetic(x_ecef: Union[ndarray, Sequence], angle_format: AngleFormat, axis: int = -1) -> ndarray

Convert ECEF Cartesian position to geodetic coordinates.

Transforms a position from Earth-Centered Earth-Fixed (ECEF) Cartesian coordinates to geodetic coordinates (longitude, latitude, altitude) using the WGS84 ellipsoid model.

Parameters:

Name Type Description Default
x_ecef ndarray or list

ECEF Cartesian position [x, y, z] in meters. Also accepts a batch of vectors with the 3 components along axis (for example shape (n, 3)).

required
angle_format AngleFormat

Angle format for output angular coordinates (RADIANS or DEGREES).

required
axis int

The axis of x_ecef along which the 3 components of a single vector lie; the remaining axes enumerate the batch. For a batch of shape (n, 3) the components lie along the last axis, so the default -1 applies; a (3, n) column layout uses axis=0.

-1

Returns:

Type Description
ndarray

numpy.ndarray: Geodetic position [longitude, latitude, altitude] where longitude is in radians or degrees, latitude is in radians or degrees, and altitude is in meters above the WGS84 ellipsoid. For batched input the output takes the batch layout of x_ecef.

Example
1
2
3
4
5
6
7
import brahe as bh
import numpy as np

# Convert ECEF to geodetic coordinates (GPS-like)
x_ecef = np.array([-1275936.0, -4797210.0, 4020109.0])  # Example location
x_geod = bh.position_ecef_to_geodetic(x_ecef, bh.AngleFormat.DEGREES)
print(f"Geodetic: lon={x_geod[0]:.4f}°, lat={x_geod[1]:.4f}°, alt={x_geod[2]:.0f}m")

Geocentric Conversions

position_geocentric_to_ecef builtin

position_geocentric_to_ecef(x_geoc: Union[ndarray, Sequence], angle_format: AngleFormat, axis: int = -1) -> ndarray

Convert geocentric position to ECEF Cartesian coordinates.

Transforms a position from geocentric spherical coordinates (longitude, latitude, radius) to Earth-Centered Earth-Fixed (ECEF) Cartesian coordinates.

Parameters:

Name Type Description Default
x_geoc ndarray or list

Geocentric position [longitude, latitude, radius] where longitude is in radians or degrees, latitude is in radians or degrees, and radius is in meters. Also accepts a batch of vectors with the 3 components along axis (for example shape (n, 3)).

required
angle_format AngleFormat

Angle format for input angular coordinates (RADIANS or DEGREES).

required
axis int

The axis of x_geoc along which the 3 components of a single vector lie; the remaining axes enumerate the batch. For a batch of shape (n, 3) the components lie along the last axis, so the default -1 applies; a (3, n) column layout uses axis=0.

-1

Returns:

Type Description
ndarray

numpy.ndarray: ECEF Cartesian position [x, y, z] in meters. For batched input the output takes the batch layout of x_geoc.

Example
1
2
3
4
5
6
7
8
import brahe as bh
import numpy as np

# Convert geocentric coordinates to ECEF
lon, lat, r = 0.0, 0.0, 6378137.0  # Equator, prime meridian, Earth's radius
x_geoc = np.array([lon, lat, r])
x_ecef = bh.position_geocentric_to_ecef(x_geoc, bh.AngleFormat.RADIANS)
print(f"ECEF position: {x_ecef}")

position_ecef_to_geocentric builtin

position_ecef_to_geocentric(x_ecef: Union[ndarray, Sequence], angle_format: AngleFormat, axis: int = -1) -> ndarray

Convert ECEF Cartesian position to geocentric coordinates.

Transforms a position from Earth-Centered Earth-Fixed (ECEF) Cartesian coordinates to geocentric spherical coordinates (longitude, latitude, radius).

Parameters:

Name Type Description Default
x_ecef ndarray or list

ECEF Cartesian position [x, y, z] in meters. Also accepts a batch of vectors with the 3 components along axis (for example shape (n, 3)).

required
angle_format AngleFormat

Angle format for output angular coordinates (RADIANS or DEGREES).

required
axis int

The axis of x_ecef along which the 3 components of a single vector lie; the remaining axes enumerate the batch. For a batch of shape (n, 3) the components lie along the last axis, so the default -1 applies; a (3, n) column layout uses axis=0.

-1

Returns:

Type Description
ndarray

numpy.ndarray: Geocentric position [longitude, latitude, radius] where longitude is in radians or degrees, latitude is in radians or degrees, and radius is in meters. For batched input the output takes the batch layout of x_ecef.

Example
1
2
3
4
5
6
7
import brahe as bh
import numpy as np

# Convert ECEF to geocentric coordinates
x_ecef = np.array([6378137.0, 0.0, 0.0])  # Point on equator, prime meridian
x_geoc = bh.position_ecef_to_geocentric(x_ecef, bh.AngleFormat.DEGREES)
print(f"Geocentric: lon={x_geoc[0]:.2f}°, lat={x_geoc[1]:.2f}°, r={x_geoc[2]:.0f}m")