sgp4
The C++ SGP4 routine that, given an Earth satellite TLE, computes its position.
What it is and what it does
SGP4 is a Python wrapper around the official C++ implementation of the Simplified General Perturbations (SGP4) and Simplified Deep Space Perturbations (SDP4) satellite propagation algorithms. It takes Two-Line Element (TLE) sets or OMM (Orbit Mean Elements Message) data—the standard formats for describing satellite orbits—and computes the satellite's position and velocity at any given time. The package automatically selects between SGP4 (for low Earth orbit, periods under 225 minutes) and SDP4 (for higher orbits) based on the orbital parameters.
The package includes a fast C++ implementation that compiles on most systems, but falls back to a slower pure-Python version if compilation fails, ensuring portability. Results are returned as raw x,y,z Cartesian coordinates in the True Equator Mean Equinox (TEME) reference frame—an Earth-centered inertial frame. The package does not perform coordinate transformations to other frames (J2000, ICRS, ECEF, WGS84) or compute latitude/longitude; those conversions are left to higher-level astronomy libraries like Skyfield, which builds on top of this one.
Use it for:
- Track International Space Station or other known satellites by loading their TLE and computing positions at specific times.
- Build a satellite pass predictor that determines when a satellite will be visible from a ground location.
- Validate or debug TLE data by checking whether parsed orbital elements produce physically reasonable positions.
- Compute satellite positions for a large batch of times and satellites using the accelerated array routine.
- Integrate satellite propagation into a mission planning or conjunction assessment tool.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Computes satellite positions in Earth orbit from TLE or OMM orbital elements using the official SGP4/SDP4 propagation algorithms, with optional C++ acceleration and pure-Python fallback.
Yes. SGP4 is actively maintained, has no runtime dependencies, compiles cleanly on most systems with a pure-Python fallback, carries an MIT license with no restrictions, and has no known vulnerabilities. Install it if you need to compute satellite positions from TLE or OMM data; it is the standard Python interface to the official SGP4 algorithm.
Install
sgp4 on PyPI
pip
pip install sgp4uv
uv add sgp4poetry
poetry add sgp4Installing sgp4
Before you install
Installs cleanly with no runtime dependencies. Actively maintained with recent releases; the C++ implementation compiles on most systems, but the package gracefully falls back to a slower pure-Python version if compilation fails.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.
Quickstart
pip install sgp4
from sgp4.api import Satrec
s = '1 25544U 98067A 19343.69339541 .00001764 00000-0 38792-4 0 9991'
t = '2 25544 51.6439 211.2001 0007417 17.6667 85.6398 15.50103472202482'
satellite = Satrec.twoline2rv(s, t)
jd, fr = 2458826.5, 0.8625
e, r, v = satellite.sgp4(jd, fr)
print(r) # position in km
print(v) # velocity in km/s
Verify before relying
- Whether the C++ extension will compile successfully on your target platform (graceful fallback exists but is slower).
- Performance characteristics of the pure-Python fallback relative to C++ for batch computations.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,!=3.8.*,!=3.9.*,>=2.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 42 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,039,036/month — #4,457 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sgp4-2.27-py3-none-any.whl
Tags
More Astronomy packages
Albumentations applies image transformations to…
permissive · top 5,000 on PyPI
convertdateConverts dates between the Gregorian calendar…
permissive · top 5,000 on PyPI
jdcalConverts between Julian dates and Gregorian or…
permissive · top 5,000 on PyPI
pyerfaPyERFA wraps the ERFA C library (Essential…
permissive · top 5,000 on PyPI
PyMeeusPyMeeus implements astronomical algorithms from…
copyleft · top 5,000 on PyPI
ephemPyEphem computes high-precision positions of…
permissive · top 5,000 on PyPI
pyorbitalPyorbital computes orbital parameters from TLE…
permissive · top 15,000 on PyPI
skyfieldSkyfield computes high-precision positions for…
permissive · top 15,000 on PyPI
jplephemLoads and queries JPL ephemeris files (SPK…
permissive · top 5,000 on PyPI
pystac-ext-satExtends PySTAC to handle satellite-specific…
permissive · top 5,000 on PyPI
astropy-iers-dataProvides IERS Earth Rotation and Leap Second…
permissive · top 5,000 on PyPI
sxtwlConverts between solar (Gregorian) and lunar…
permissive · top 15,000 on PyPI
pygeodesyPyGeodesy provides pure Python implementations…
permissive · top 15,000 on PyPI