Rust implementation of EGM2008 geoid grid interpolation and grid extraction.
The project works with the EGM2008 2.5′ × 2.5′ global geoid undulation grid and provides:
- geoid undulation interpolation at arbitrary WGS84 coordinates
- extraction of grid subsets
- export of grid values in ASCII format
- numerical regression tests against reference results
EGM2008 is a global Earth gravitational model.
This project operates on the EGM2008 geoid undulation grid sampled on a 2.5′ × 2.5′ latitude/longitude grid.
Grid characteristics:
- coordinate system: WGS84
- spacing: 2.5 arc-minutes
- rows: 4321
- columns: 8640
- value type: geoid undulation (meters)
- coverage: global
- latitude range: 90°N to 90°S
- longitude range: 0°E to 360°E
The grid contains point values located at grid corners.
The north-west grid point corresponds to:
Latitude = 90.000000°
Longitude = 0.000000°
Values located on the 0° meridian appear once and are not repeated at 360°.
cargo build --releasecargo run --releaseAvailable modes:
1 = Extract grid band (ASCII)
2 = Extract grid point records (ASCII)
3 = Interpolate coordinates from INPUT.DAT
Results are written to:
OUTPUT.DAT
.
├── src
│ ├── app.rs
│ ├── grid.rs
│ ├── interp.rs
│ ├── lib.rs
│ ├── main.rs
│ └── stats.rs
│
├── tests
│ ├── app_test.rs
│ ├── grid_geometry_regression.rs
│ ├── grid_test.rs
│ ├── integration_test.rs
│ ├── interp_test.rs
│ ├── lib_test.rs
│ ├── numerical_regression.rs
│ ├── stats_test.rs
│ ├── expected_output.dat
│ └── test_points.dat
│
└── .github
└── workflows
└── ci.yml
Run all tests:
cargo testRun numerical regression tests:
cargo test --test numerical_regression -- --nocaptureRun Clippy:
cargo clippy --all-targets --all-features -- -D warningsThe interpolation implementation is verified through:
- unit tests
- integration tests
- geometry regression tests
- numerical regression tests
Regression tests compare interpolated values against known reference outputs.
Example:
Checked points : 17
Maximum diff : 0.518259 m
Failures : 0
Tolerance : 1.0 m
Most regression points match within a few tenths of a millimeter.
The supported grid contains:
4321 rows × 8640 columns
Each value is stored as:
REAL*4 (32-bit floating point)
The grid represents geoid undulations in meters.
Records are stored by parallel band:
- first record = northern-most latitude
- first value in each record = western-most longitude
- longitude coverage = 0° to 360°
- latitude coverage = 90°N to 90°S
The implementation supports:
- bilinear interpolation
- spline interpolation
For interpolation, the grid is loaded into memory and padded using:
- horizontal wrap-around padding
- north-pole padding
- south-pole padding
The padding strategy follows the assumptions used by the interpolation algorithm near grid boundaries and poles.
A one-row indexing offset was identified during regression testing.
The grid loading stage must populate:
grid[ii + IW - 1][j + IW]instead of:
grid[ii + IW][j + IW]Using the second form leaves the first physical grid row uninitialized and produces incorrect interpolation results near the poles.
The issue became visible during numerical validation at latitudes close to ±90° and was corrected before final regression testing.
Citation:
Pavlis, N.K., Holmes, S.A., Kenyon, S.C., and Factor, J.K. An Earth Gravitational Model to Degree 2160: EGM2008. European Geosciences Union General Assembly, Vienna, Austria, April 13–18, 2008.
Additional information about EGM2008 can be found through the NGA Earth Information portal:
This repository contains Rust source code only.
Users must obtain the required EGM2008 grid data separately and place it in the working directory before running interpolation or grid extraction operations.