egm96
GPS reports altitude as height above the WGS 84 reference ellipsoid, a smooth mathematical surface that can sit tens of meters away from actual sea level. EGM96, the 1996 Earth Gravitational Model from the U.S. National Geospatial-Intelligence Agency, describes where mean sea level lies relative to that ellipsoid. The gap between the two is the geoid undulation; subtracting it from a GPS height gives an approximate height above sea level.
This package looks up the EGM96 undulation for any coordinate.
Usage
import egm96
egm96.undulation(48.14, 11.58) # 45.48 (meters, near Munich)
The undulation is the height of the geoid above the WGS 84 ellipsoid. Subtract
it from a GPS ellipsoidal height h to get a height above mean sea level:
H = h - egm96.undulation(lat, lon)
Coordinates are in degrees. Longitude wraps at ±180° and latitude is clamped to ±90°. Both arguments also accept NumPy arrays, which broadcast together and return an array.
Accuracy and size
The package bundles the complete EGM96 5' grid (2161 × 4321 points) and interpolates it bilinearly. Against GeographicLib's cubic evaluation of the same model, over 6000 random points, the largest difference is < 0.06 m - negligible next to EGM96's own ~0.5–1 m uncertainty relative to the real geoid.
Bilinear error grows quickly if the grid is coarsened, so it is worth keeping the full resolution:
| Grid spacing | Max error vs EGM96 |
|---|---|
| 0.25° (15') | 0.5 m |
| 0.17° (10') | 0.2 m |
| 0.083° (5', used) | 0.05 m |
Stored plainly the grid is about 13 MB. The geoid is smooth, so encoding it as second differences (in centimeters) and deflating the result shrinks it to 3.1 MB with no loss; the loader reconstructs the values with two cumulative sums.
Grid Data
src/egm96/data/egm96-5.npz is built from the source geoid at packaging time and
is not stored in the repository. generate-egm96-grid downloads the 5' PGM from
GeographicLib — only if it is not already cached locally — and writes the
.npz. CI runs the generator before uv build, so the grid ends up inside the
wheel, and installing from PyPI needs no network access at runtime.
To build locally:
uv sync
uv run ./generate-egm96-grid
uv build
License
MIT (see LICENSE). EGM96 is a work of the U.S. Government (NGA, NASA, and Ohio State University) in the public domain; the 5' dataset is redistributed by the MIT-licensed GeographicLib.
Metadata
Release files for egm96 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| egm96-0.3.0.tar.gz | 3.1 MB | Without provenance | Details for egm96-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| egm96-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for egm96-0.3.0-py3-none-any.whl |
Total release size: 6.2 MB
Release files / egm96-0.3.0.tar.gz
| Download URL | egm96-0.3.0.tar.gz |
|---|---|
| Size | 3.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c0fdfc72971dc61d576bc7993bd992ea813756da1f83d4d25350e277b9099d1
|
|
BLAKE2b-256 checksum How to use checksums |
1f463a266648c0bf2d6189b2624ce080bd9fb9da85149b651b065c5446a65b4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / egm96-0.3.0-py3-none-any.whl
| Download URL | egm96-0.3.0-py3-none-any.whl |
|---|---|
| Size | 3.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
230ea84b48130c6742bae19db94cd5d7737ecd6e3a2ab0b27059f1b807732076
|
|
BLAKE2b-256 checksum How to use checksums |
825886e8c7b335c190121e3ded407a0935048041bc2709b2839c51951555a7f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for egm96 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.