GeoidEval [ -n name ] [ -d dir ] [ -l ] [ -a | -c south west north east ] [ -w ] [ -z zone ] [ --msltohae ] [ --haetomsl ] [ -v ] [ --comment-delimiter commentdelim ] [ --version | -h | --help ] [ --input-file infile | --input-string instring ] [ --line-separator linesep ] [ --output-file outfile ]
GeoidEval reads in positions on standard input and prints out the corresponding heights of the geoid above the WGS84 ellipsoid on standard output.
Positions are given as latitude and longitude, UTM/UPS, or MGRS, in any of the formats accepted by GeoConvert(1). (MGRS coordinates signify the center of the corresponding MGRS square.) If the -z option is specified then the specified zone is prepended to each line of input (which must be in UTM/UPS coordinates). This allows a file with UTM eastings and northings in a single zone to be used as standard input.
More accurate results for the geoid height are provided by Gravity(1). This utility can also compute the direction of gravity accurately.
The height of the geoid above the ellipsoid, N, is sometimes called the geoid undulation. It can be used to convert a height above the ellipsoid, h, to the corresponding height above the geoid (the orthometric height, roughly the height above mean sea level), H, using the relations
h = N + H, H = -N + h.
- -n name
use geoid name instead of the default
egm96-5. See “Geoids”.
- -d dir
read geoid data from dir instead of the default. See “Geoids”.
use bilinear interpolation instead of cubic. See “Interpolation”.
cache the entire data set in memory. See “Cache”.
- -c south west north east
cache the data bounded by south west north east in memory. The first two arguments specify the SW corner of the cache and the last two arguments specify the NE corner. The -w flag specifies that longitude precedes latitude for these corners, provided that it appears before -c. See “Cache”.
toggle the longitude first flag (it starts off); if the flag is on, then when reading geographic coordinates, longitude precedes latitude (this can be overridden by a hemisphere designator, N, S, E, W).
- -z zone
prefix each line of input by zone, e.g.,
38n. This should be used when the input consists of UTM/UPS eastings and northings.
standard input should include a final token on each line which is treated as a height (in meters) above the geoid and the output echoes the input line with the height converted to height above ellipsoid (HAE). If -z zone is specified then the third token is treated as the height; this makes it possible to convert LIDAR data where each line consists of: easting northing height intensity.
this is similar to --msltohae except that the height token is treated as a height (in meters) above the ellipsoid and the output echoes the input line with the height converted to height above the geoid (MSL).
print information about the geoid on standard error before processing the input.
- --comment-delimiter commentdelim
set the comment delimiter to commentdelim (e.g., “#” or “//”). If set, the input lines will be scanned for this delimiter and, if found, the delimiter and the rest of the line will be removed prior to processing and subsequently appended to the output line (separated by a space).
print version and exit.
print usage, the default geoid path and name, and exit.
print full documentation and exit.
- --input-file infile
read input from the file infile instead of from standard input; a file name of “-” stands for standard input.
- --input-string instring
read input from the string instring instead of from standard input. All occurrences of the line separator character (default is a semicolon) in instring are converted to newlines before the reading begins.
- --line-separator linesep
set the line separator character to linesep. By default this is a semicolon.
- --output-file outfile
write output to the file outfile instead of to standard output; a file name of “-” stands for standard output.
GeoidEval computes geoid heights by interpolating on the data in a regularly spaced table (see “Interpolation”). The following geoid tables are available (however, some may not be installed):
bilinear error cubic error name geoid grid max rms max rms egm84-30 EGM84 30' 1.546 m 70 mm 0.274 m 14 mm egm84-15 EGM84 15' 0.413 m 18 mm 0.021 m 1.2 mm egm96-15 EGM96 15' 1.152 m 40 mm 0.169 m 7.0 mm egm96-5 EGM96 5' 0.140 m 4.6 mm .0032 m 0.7 mm egm2008-5 EGM2008 5' 0.478 m 12 mm 0.294 m 4.5 mm egm2008-2_5 EGM2008 2.5' 0.135 m 3.2 mm 0.031 m 0.8 mm egm2008-1 EGM2008 1' 0.025 m 0.8 mm .0022 m 0.7 mm
By default, the
egm96-5 geoid is used. This may changed by setting the environment variable
GEOGRAPHICLIB_GEOID_NAME or with the -n option. The errors listed here are estimates of the quantization and interpolation errors in the reported heights compared to the specified geoid.
The geoid data will be loaded from a directory specified at compile time. This may changed by setting the environment variables
GEOGRAPHICLIB_DATA, or with the -d option. The -h option prints the default geoid path and name. Use the -v option to ascertain the full path name of the data file.
Instructions for downloading and installing geoid data are available at <https://geographiclib.sourceforge.io/html/geoid.html#geoidinst>.
NOTE: all the geoids above apply to the WGS84 ellipsoid (a = 6378137 m, f = 1/298.257223563) only.
Cubic interpolation is used to compute the geoid height unless -l is specified in which case bilinear interpolation is used. The cubic interpolation is based on a least-squares fit of a cubic polynomial to a 12-point stencil
. 1 1 . 1 2 2 1 1 2 2 1 . 1 1 .
The cubic is constrained to be independent of longitude when evaluating the height at one of the poles. Cubic interpolation is considerably more accurate than bilinear; however it results in small discontinuities in the returned height on cell boundaries.
By default, the data file is randomly read to compute the geoid heights at the input positions. Usually this is sufficient for interactive use. If many heights are to be computed, use -c south west north east to notify GeoidEval to read a rectangle of data into memory; heights within the this rectangle can then be computed without any disk access. If -a is specified all the geoid data is read; in the case of
egm2008-1, this requires about 0.5 GB of RAM. The evaluation of heights outside the cached area causes the necessary data to be read from disk. Use the -v option to verify the size of the cache.
Regardless of whether any cache is requested (with the -a or -c options), the data for the last grid cell in cached. This allows the geoid height along a continuous path to be returned with little disk overhead.
Override the compile-time default geoid name of
egm96-5. The -h option reports the value of GEOGRAPHICLIB_GEOID_NAME, if defined, otherwise it reports the compile-time value. If the -n name option is used, then name takes precedence.
Override the compile-time default geoid path. This is typically
/usr/local/share/GeographicLib/geoidson Unix-like systems and
C:/ProgramData/GeographicLib/geoidson Windows systems. The -h option reports the value of GEOGRAPHICLIB_GEOID_PATH, if defined, otherwise it reports the compile-time value. If the -d dir option is used, then dir takes precedence.
Another way of overriding the compile-time default geoid path. If it is set (and if GEOGRAPHICLIB_GEOID_PATH is not set), then $GEOGRAPHICLIB_DATA/geoids is used.
An illegal line of input will print an error message to standard output beginning with
ERROR: and causes GeoidEval to return an exit code of 1. However, an error does not cause GeoidEval to terminate; following lines will be converted.
The geoid is usually approximated by an “earth gravity model”. The models published by the NGA are:
An earth gravity model published by the NGA in 1984, <https://earth-info.nga.mil/index.php?dir=wgs84&action=wgs84#tab_egm84>.
An earth gravity model published by the NGA in 1996, <https://earth-info.nga.mil/index.php?dir=wgs84&action=wgs84#tab_egm96>.
An earth gravity model published by the NGA in 2008, <https://earth-info.nga.mil/index.php?dir=wgs84&action=wgs84#tab_egm2008>.
World Geodetic System 1984, <https://en.wikipedia.org/wiki/WGS84>.
Height above the WGS84 ellipsoid.
Mean sea level, used as a convenient short hand for the geoid. (However, typically, the geoid differs by a few meters from mean sea level.)
The height of the EGM96 geoid at Timbuktu
echo 16:46:33N 3:00:34W | GeoidEval => 28.7068 -0.02e-6 -1.73e-6
The first number returned is the height of the geoid and the 2nd and 3rd are its slopes in the northerly and easterly directions.
Convert a point in UTM zone 18n from MSL to HAE
echo 531595 4468135 23 | GeoidEval --msltohae -z 18n => 531595 4468135 -10.842
GeoConvert(1), Gravity(1), geographiclib-get-geoids(8).
An online version of this utility is availbable at <https://geographiclib.sourceforge.io/cgi-bin/GeoidEval>.
GeoidEval was written by Charles Karney.
GeoidEval was added to GeographicLib, <https://geographiclib.sourceforge.io>, in 2009-09.