pymap3d Library

3.2.0 · active · verified Sun Apr 12

pymap3d is a pure Python library (with no external prerequisites) providing various coordinate conversions. It follows the conventions of several popular Matlab routines for geospatial and attitude transformations. The current version is 3.2.0, and it maintains an active development status with regular updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates core coordinate conversion functionalities. It converts geodetic coordinates to ECEF, then converts ECEF back to geodetic to show round-trip consistency. Finally, it illustrates conversion from ECEF to ECI, highlighting the need for a specific timestamp.

import pymap3d as pm
import datetime

# Example Geodetic (Lat, Lon, Alt) to ECEF (Earth-Centered, Earth-Fixed) conversion
lat, lon, alt = 42.0, -82.0, 200.0  # Latitude (deg), Longitude (deg), Altitude (meters)
x, y, z = pm.geodetic2ecef(lat, lon, alt)
print(f"ECEF coordinates: x={x:.2f}m, y={y:.2f}m, z={z:.2f}m")

# Example ECEF to Geodetic conversion
lat2, lon2, alt2 = pm.ecef2geodetic(x, y, z)
print(f"Geodetic coordinates: lat={lat2:.2f}deg, lon={lon2:.2f}deg, alt={alt2:.2f}m")

# Example ECEF to ECI (Earth-Centered Inertial) conversion (requires datetime)
# For a specific time, you need the corresponding position and velocity.
time = datetime.datetime(2023, 1, 20, 12, 0, 0, tzinfo=datetime.timezone.utc)
x_eci, y_eci, z_eci = pm.ecef2eci(x, y, z, time)
print(f"ECI coordinates (at {time}): x={x_eci:.2f}m, y={y_eci:.2f}m, z={z_eci:.2f}m")

view raw JSON →