/usr/share/doc/geographiclib/html/geoid.html is in geographiclib-doc 1.45-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.9.1"/>
<title>GeographicLib: Geoid height</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script><script src="/usr/share/javascript/mathjax/MathJax.js/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">GeographicLib
 <span id="projectnumber">1.45</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.9.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title"><a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> height </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><center> Back to <a class="el" href="other.html">Implementations in other languages</a>. Forward to <a class="el" href="gravity.html">Gravity models</a>. Up to <a class="el" href="index.html#contents">Contents</a>. </center><p>The gravitational equipotential surface approximately coinciding with mean sea level is called the geoid. The <a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> class and the <a href="GeoidEval.1.html">GeoidEval</a> utility evaluate the height of the geoid above the WGS84 ellipsoid. This can be used to convert heights above mean sea level to heights above the WGS84 ellipsoid. Because the normal to the ellipsoid differs from the normal to the geoid (the direction of a plumb line) there is a slight ambiguity in the measurement of heights; however for heights up to 10 km this ambiguity is only 1 mm.</p>
<p>The geoid is usually approximated by an "earth gravity model" (EGM). The models published by the NGA are:</p><ul>
<li><b>EGM84</b>: <a href="http://earth-info.nga.mil/GandG/wgs84/gravitymod/wgs84_180/wgs84_180.html">http://earth-info.nga.mil/GandG/wgs84/gravitymod/wgs84_180/wgs84_180.html</a></li>
<li><b>EGM96</b>: <a href="http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm96/egm96.html">http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm96/egm96.html</a></li>
<li><b>EGM2008</b>: <a href="http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm2008">http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm2008</a></li>
</ul>
<p><a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> offers a uniform way to handle all 3 geoids at a variety of grid resolutions. (In contrast, the software tools that NGA offers are different for each geoid, and the interpolation programs are different for each grid resolution. In addition these tools are written in Fortran with is nowadays difficult to integrate with other software.)</p>
<p>The height of the geoid above the ellipsoid, <em>N</em>, is sometimes called the geoid undulation. It can be used to convert a height above the ellipsoid, <em>h</em>, to the corresponding height above the geoid (the orthometric height, roughly the height above mean sea level), <em>H</em>, using the relations</p>
<p>   <em>h</em> = <em>N</em> + <em>H</em>;   <em>H</em> = −<em>N</em> + <em>h</em>.</p>
<p>Unlike other components of <a class="el" href="namespaceGeographicLib.html" title="Namespace for GeographicLib. ">GeographicLib</a>, there is a appreciable error in the results obtained (at best, the RMS error is 1 mm). However the class provides methods to report the maximum and RMS errors in the results. The class also returns the gradient of the geoid. This can be used to estimate the direction of a plumb line relative to the WGS84 ellipsoid.</p>
<p>The <a class="el" href="classGeographicLib_1_1GravityModel.html" title="Model of the earth's gravity field. ">GravityModel</a> class calculates geoid heights using the underlying gravity model. This is slower then <a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> but considerably more accurate. This class also can accurately compute all the components of the acceleration due to gravity (and hence the direction of plumb line).</p>
<p>Go to</p><ul>
<li><a class="el" href="geoid.html#geoidinst">Installing the geoid datasets</a></li>
<li><a class="el" href="geoid.html#geoidformat">The format of the geoid data files</a></li>
<li><a class="el" href="geoid.html#geoidinterp">Interpolating the geoid data</a></li>
<li><a class="el" href="geoid.html#geoidcache">Caching the geoid data</a></li>
<li><a class="el" href="geoid.html#testgeoid">Test data for geoids</a></li>
</ul>
<h1><a class="anchor" id="geoidinst"></a>
Installing the geoid datasets</h1>
<p>The geoid heights are computed using interpolation into a rectangular grid. The grids are read from data files which have been are computed using the NGA synthesis programs in the case of the EGM84 and EGM96 models and using the NGA binary gridded data files in the case of EGM2008. These data files are available for download: </p><center> <table class="doxtable">
<caption align="bottom">Available geoid data files</caption>
<tr>
<th rowspan="2">name </th><th rowspan="2">geoid </th><th rowspan="2">grid </th><th rowspan="2">size<br />
(MB) </th><th colspan="3"><center>Download Links (size, MB)</center> </th></tr>
<tr>
<th>tar file </th><th>Windows<br />
installer </th><th>zip file </th></tr>
<tr>
<td>egm84-30 </td><td>EGM84 </td><td><center>30'</center> </td><td><center>0.6</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm84-30.tar.bz2">link</a> (0.5)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm84-30.exe">link</a> (0.8)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm84-30.zip">link</a> (0.5)</center> </td></tr>
<tr>
<td>egm84-15 </td><td>EGM84 </td><td><center>15'</center> </td><td><center>2.1</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm84-15.tar.bz2">link</a> (1.5)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm84-15.exe">link</a> (1.9)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm84-15.zip">link</a> (2.0)</center> </td></tr>
<tr>
<td>egm96-15 </td><td>EGM96 </td><td><center>15'</center> </td><td><center>2.1</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm96-15.tar.bz2">link</a> (1.5)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm96-15.exe">link</a> (1.9)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm96-15.zip">link</a> (2.0)</center> </td></tr>
<tr>
<td>egm96-5 </td><td>EGM96 </td><td><center>5'</center> </td><td><center> 19</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm96-5.tar.bz2">link</a> (11)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm96-5.exe">link</a> (11)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm96-5.zip">link</a> (17)</center> </td></tr>
<tr>
<td>egm2008-5 </td><td>EGM2008 </td><td><center>5'</center> </td><td><center> 19</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm2008-5.tar.bz2">link</a> (11)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm2008-5.exe">link</a> (11)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm2008-5.zip">link</a> (17)</center> </td></tr>
<tr>
<td>egm2008-2_5 </td><td>EGM2008 </td><td><center>2.5'</center> </td><td><center> 75</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm2008-2_5.tar.bz2">link</a> (35)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm2008-2_5.exe">link</a> (33)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm2008-2_5.zip">link</a> (65)</center> </td></tr>
<tr>
<td>egm2008-1 </td><td>EGM2008 </td><td><center>1'</center> </td><td><center>470</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm2008-1.tar.bz2">link</a> (170)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm2008-1.exe">link</a> (130)</center> </td><td><center> <a href="https://sf.net/projects/geographiclib/files/geoids-distrib/egm2008-1.zip">link</a> (390)</center> </td></tr>
</table>
</center><p> The "size" column is the size of the uncompressed data and it also gives the memory requirements for caching the entire dataset using the <a class="el" href="classGeographicLib_1_1Geoid.html#a482c6482d5ab4c5d661210327848170e">Geoid::CacheAll</a> method. At a minimum you should install egm96-5 and either egm2008-1 or egm2008-2_5. Many applications use the EGM96 geoid, however the use of EGM2008 is growing. (EGM84 is rarely used now.)</p>
<p>For Linux and Unix systems, <a class="el" href="namespaceGeographicLib.html" title="Namespace for GeographicLib. ">GeographicLib</a> provides a shell script geographiclib-get-geoids (typically installed in /usr/local/sbin) which automates the process of downloading and installing the geoid data. For example </p><pre class="fragment"> geographiclib-get-geoids best # to install egm84-15, egm96-5, egm2008-1
geographiclib-get-geoids -h # for help
</pre><p> This script should be run as a user with write access to the installation directory, which is typically /usr/local/share/GeographicLib (this can be overridden with the -p flag), and the data will then be placed in the "geoids" subdirectory.</p>
<p>Windows users should download and run the Windows installers. These will prompt for an installation directory with the default being </p><pre class="fragment"> C:/ProgramData/GeographicLib
</pre><p> (which you probably should not change) and the data is installed in the "geoids" sub-directory. (The second directory name is an alternate name that Windows 7 uses for the "Application Data" directory.)</p>
<p>Otherwise download <em>either</em> the tar.bz2 file <em>or</em> the zip file (they have the same contents). If possible use the tar.bz2 files, since these are compressed about 2 times better than the zip file. To unpack these, run, for example </p><pre class="fragment"> mkdir -p /usr/local/share/GeographicLib
tar xofjC egm96-5.tar.bz2 /usr/local/share/GeographicLib
tar xofjC egm2008-2_5.tar.bz2 /usr/local/share/GeographicLib
etc.
</pre><p> and, again, the data will be placed in the "geoids" subdirectory.</p>
<p>However you install the geoid data, all the datasets should be installed in the same directory. <a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> and <a href="GeoidEval.1.html">GeoidEval</a> uses a compile time default to locate the datasets. This is</p><ul>
<li>/usr/local/share/GeographicLib/geoids, for non-Windows systems</li>
<li>C:/ProgramData/GeographicLib/geoids, for Windows systems</li>
</ul>
<p>consistent with the examples above. This may be overridden at run-time by defining the GEOGRAPHICLIB_GEOID_PATH or the GEOGRAPHICLIB_DATA environment variables; see <a class="el" href="classGeographicLib_1_1Geoid.html#a2daf81f5c648cf190a83981f441ab08f">Geoid::DefaultGeoidPath()</a> for details. Finally, the path may be set using the optional second argument to the <a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> constructor or with the "-d" flag to <a href="GeoidEval.1.html">GeoidEval</a>. Supplying the "-h" flag to <a href="GeoidEval.1.html">GeoidEval</a> reports the default geoid path for that utility. The "-v" flag causes GeoidEval to report the full path name of the data file it uses.</p>
<h1><a class="anchor" id="geoidformat"></a>
The format of the geoid data files</h1>
<p>The gridded data used by the <a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> class is stored in 16-bit PGM files. Thus the data for egm96-5 might be stored in the file</p><ul>
<li>/usr/local/share/GeographicLib/geoids/egm96-5.pgm</li>
</ul>
<p>PGM simple graphic format with the following properties</p><ul>
<li>it is well documented <a href="http://netpbm.sf.net/doc/pgm.html">here</a>;</li>
<li>there are no separate "little-endian" and "big-endian" versions;</li>
<li>it uses 1 or 2 bytes per pixel;</li>
<li>pixels can be randomly accessed;</li>
<li>comments can be added to the file header;</li>
<li>it is sufficiently simple that it can be easily read without using the <a href="http://netpbm.sf.net/doc/libnetpbm.html">libnetpbm</a> library (and thus we avoid adding a software dependency to <a class="el" href="namespaceGeographicLib.html" title="Namespace for GeographicLib. ">GeographicLib</a>).</li>
</ul>
<p>The major drawback of this format is that since there are only 65535 possible pixel values, the height must be quantized to 3 mm. However, the resulting quantization error (up to 1.5 mm) is typically smaller than the linear interpolation errors. The comments in the header for egm96-5 are </p><pre class="fragment"> # Geoid file in PGM format for the GeographicLib::Geoid class
# Description WGS84 EGM96, 5-minute grid
# URL http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm96/egm96.html
# DateTime 2009-08-29 18:45:03
# MaxBilinearError 0.140
# RMSBilinearError 0.005
# MaxCubicError 0.003
# RMSCubicError 0.001
# Offset -108
# Scale 0.003
# Origin 90N 0E
# AREA_OR_POINT Point
# Vertical_Datum WGS84
</pre><p> Of these lines, the Scale and Offset lines are required and define the conversion from pixel value to height (in meters) using <em>height</em> = <em>offset</em> + <em>scale</em> <em>pixel</em>. The <a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> constructor also reads the Description, DateTime, and error lines (if present) and stores the resulting data so that it can be returned by <a class="el" href="classGeographicLib_1_1Geoid.html#a37d76bcfe0ddf9b84042d701c312e941">Geoid::Description</a>, <a class="el" href="classGeographicLib_1_1Geoid.html#a9cd7304b5df37001f4ad3c91cdbc56f4">Geoid::DateTime</a>, <a class="el" href="classGeographicLib_1_1Geoid.html#aff538da14578a02c551b411a899e567a">Geoid::MaxError</a>, and <a class="el" href="classGeographicLib_1_1Geoid.html#a207f98316d20a5b9d47846e559c5e2a2">Geoid::RMSError</a> methods. The other lines serve as additional documentation but are not used by this class. Accompanying egm96-5.pgm (and similarly with the other geoid data files) are two files egm96-5.wld and egm96-5.pgm.aux.xml. The first is an ESRI "world" file and the second supplies complete projection metadata for use by <a href="http://www.gdal.org">GDAL</a>. Neither of these files is read by <a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a>.</p>
<p>You can use gdal_translate to convert the data files to a standard GeoTiff, e.g., with </p><pre class="fragment"> gdal_translate -ot Float32 -scale 0 65000 -108 87 egm96-5.pgm egm96-5.tif
</pre><p> The arguments to -scale here are specific to the Offset and Scale parameters used in the pgm file (note 65000 * 0.003 − 108 = 87). You can check these by running <a href="GeoidEval.1.html">GeoidEval</a> with the "-v" option.</p>
<p>Here is a sample script which uses GDAL to create a 1-degree squared grid of geoid heights at 3" resolution (matching DTED1) by bilinear interpolation. </p><pre class="fragment"> #! /bin/sh
lat=37
lon=067
res=3 # resolution in seconds
TEMP=`mktemp junkXXXXXXXXXX` # temporary file for GDAL
gdalwarp -q -te `echo $lon $lat $res | awk '{
lon = $1; lat = $2; res = $3;
printf "%.14f %.14f %.14f %.14f",
lon -0.5*res/3600, lat -0.5*res/3600,
lon+1+0.5*res/3600, lat+1+0.5*res/3600;
}'` -ts $((3600/res+1)) $((3600/res+1)) -r bilinear egm96-5.tif $TEMP
gdal_translate -quiet \
-mo AREA_OR_POINT=Point \
-mo Description="WGS84 EGM96, $res-second grid" \
-mo Vertical_Datum=WGS84 \
-mo Tie_Point_Location=pixel_corner \
$TEMP e$lon-n$lat.tif
rm -f $TEMP
</pre><p>Because the pgm files are uncompressed, they can take up a lot of disk space. Some compressed formats compress in tiles and so might be compatible with the requirement that the data can be randomly accessed. In particular gdal_translate can be used to convert the pgm files to compressed tiff files with </p><pre class="fragment">gdal_translate -co COMPRESS=LZW -co PREDICTOR=2 \
-co TILED=YES -co BLOCKXSIZE=256 -co BLOCKYSIZE=256 \
egmyy-g.pgm egmyy-g.tif
</pre><p> The resulting files sizes are </p><pre class="fragment"> pgm tif
egm84-30 0.6 MB 0.5 MB
egm84-15 2.1 MB 1.4 MB
egm96-15 2.1 MB 1.5 MB
egm96-5 19 MB 8.5 MB
egm2008-5 19 MB 9.8 MB
egm2008-2_5 75 MB 28 MB
egm2008-1 470 MB 97 MB
</pre><p> Currently, there are no plans for <a class="el" href="namespaceGeographicLib.html" title="Namespace for GeographicLib. ">GeographicLib</a> to support this compressed format.</p>
<h1><a class="anchor" id="geoidinterp"></a>
Interpolating the geoid data</h1>
<p><a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> evaluates the geoid height using bilinear or cubic interpolation. The gradient of the geoid height is obtained by differentiating the interpolated height and referencing the result to distance on the WGS84 ellipsoid.</p>
<p><b>WARNING</b>: Although <a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> computes the gradient of the geoid height, this is subject to large quantization errors as a result of the way that the geoid data is stored. This is particularly acute for fine grids, at high latitudes, and for the easterly gradient. If you need to compute the direction of the acceleration due to gravity accurately, you should use <a class="el" href="classGeographicLib_1_1GravityModel.html#a2dc8bf4cfa3c1914f4c7e93a5a3b3eac">GravityModel::Gravity</a>.</p>
<p>The bilinear interpolation is based on the values at the 4 corners of the enclosing cell. The interpolated height is a continuous function of position; however the gradient has discontinuities are cell boundaries. The quantization of the data files exacerbates the errors in the gradients.</p>
<p>The cubic interpolation is a least-squares fit to the values on a 12-point stencil with weights as follows: </p><pre class="fragment"> . 1 1 .
1 2 2 1
1 2 2 1
. 1 1 .
</pre><p> 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 interpolation; however, in this implementation there are small discontinuities in the heights are cell boundaries. The over-constrained cubic fit slightly reduces the quantization errors on average.</p>
<p>The algorithm for the least squares fit is taken from, F. H. Lesh, Multi-dimensional least-squares polynomial curve fitting, CACM 2, 29–30 (1959). This algorithm is not part of <a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a>; instead it is implemented as <a href="https://en.wikipedia.org/wiki/Maxima_(software)">Maxima</a> code which is used to precompute the matrices to convert the function values on the stencil into the coefficients from the cubic polynomial. This code is included as a comment in <a class="el" href="Geoid_8cpp.html" title="Implementation for GeographicLib::Geoid class. ">Geoid.cpp</a>.</p>
<p>The interpolation methods are quick and give good accuracy. Here is a summary of the combined quantization and interpolation errors for the heights. </p><center><table class="doxtable">
<caption align="bottom">Interpolation and quantization errors for geoid heights</caption>
<tr>
<th rowspan="2">name </th><th rowspan="2">geoid </th><th rowspan="2">grid </th><th colspan="2"><center>bilinear error</center> </th><th colspan="2"><center>cubic error</center> </th></tr>
<tr>
<th><center>max</center></th><th><center>rms</center> </th><th><center>max</center></th><th><center>rms</center> </th></tr>
<tr>
<td>egm84-30 </td><td>EGM84 </td><td><center>30' </center> </td><td><center>1.546 m</center></td><td><center>70 mm</center> </td><td><center>0.274 m</center></td><td><center>14 mm</center> </td></tr>
<tr>
<td>egm84-15 </td><td>EGM84 </td><td><center>15' </center> </td><td><center>0.413 m</center></td><td><center>18 mm</center> </td><td><center>0.021 m</center></td><td><center>1.2 mm</center> </td></tr>
<tr>
<td>egm96-15 </td><td>EGM96 </td><td><center>15' </center> </td><td><center>1.152 m</center></td><td><center>40 mm</center> </td><td><center>0.169 m</center></td><td><center>7.0 mm</center> </td></tr>
<tr>
<td>egm96-5 </td><td>EGM96 </td><td><center> 5' </center> </td><td><center>0.140 m</center></td><td><center>4.6 mm</center> </td><td><center>0.0032 m</center></td><td><center>0.7 mm</center> </td></tr>
<tr>
<td>egm2008-5 </td><td>EGM2008</td><td><center> 5' </center> </td><td><center>0.478 m</center></td><td><center>12 mm</center> </td><td><center>0.294 m</center></td><td><center>4.5 mm</center> </td></tr>
<tr>
<td>egm2008-2_5</td><td>EGM2008</td><td><center> 2.5'</center> </td><td><center>0.135 m</center></td><td><center>3.2 mm</center> </td><td><center>0.031 m</center></td><td><center>0.8 mm</center> </td></tr>
<tr>
<td>egm2008-1 </td><td>EGM2008</td><td><center> 1' </center> </td><td><center>0.025 m</center></td><td><center>0.8 mm</center> </td><td><center>0.0022 m</center></td><td><center>0.7 mm</center> </td></tr>
</table>
</center><p> The errors are with respect to the specific NGA earth gravity model (not to any "real" geoid). The RMS values are obtained using 5 million uniformly distributed random points. The maximum values are obtained by evaluating the errors using a different grid with points at the centers of the original grid. (The RMS difference between EGM96 and EGM2008 is about 0.5 m. The RMS difference between EGM84 and EGM96 is about 1.5 m.)</p>
<p>The errors in the table above include the quantization errors that arise because the height data that <a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> uses are quantized to 3 mm. If, instead, <a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> were to use data files without such quantization artifacts, the overall error would be reduced <em>but only modestly</em> as shown in the following table, where only the changed rows are included and where the changed entries are given in bold: </p><center><table class="doxtable">
<caption align="bottom">Interpolation (only!) errors for geoid heights</caption>
<tr>
<th rowspan="2">name </th><th rowspan="2">geoid </th><th rowspan="2">grid </th><th colspan="2"><center>bilinear error</center> </th><th colspan="2"><center>cubic error</center> </th></tr>
<tr>
<th><center>max</center></th><th><center>rms</center> </th><th><center>max</center></th><th><center>rms</center> </th></tr>
<tr>
<td>egm96-5 </td><td>EGM96 </td><td><center> 5' </center> </td><td><center>0.140 m</center></td><td><center>4.6 mm</center> </td><td><center><b>0.0026 m</b></center></td><td><center><b>0.1 mm</b></center> </td></tr>
<tr>
<td>egm2008-2_5</td><td>EGM2008</td><td><center> 2.5'</center> </td><td><center>0.135 m</center></td><td><center>3.2 mm</center> </td><td><center>0.031 m</center></td><td><center><b>0.4 mm</b></center> </td></tr>
<tr>
<td>egm2008-1 </td><td>EGM2008</td><td><center> 1' </center> </td><td><center>0.025 m</center></td><td><center><b>0.6 mm</b></center> </td><td><center><b>0.0010 m</b></center></td><td><center><b>0.011 mm</b></center> </td></tr>
</table>
</center><h1><a class="anchor" id="geoidcache"></a>
Caching the geoid data</h1>
<p>A simple way of calling <a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> is as follows </p><div class="fragment"><div class="line"><span class="preprocessor">#include <<a class="code" href="Geoid_8hpp.html">GeographicLib/Geoid.hpp</a>></span></div>
<div class="line"><span class="preprocessor">#include <iostream></span></div>
<div class="line">...</div>
<div class="line">GeographicLib::Geoid g(<span class="stringliteral">"egm96-5"</span>);</div>
<div class="line"><span class="keywordtype">double</span> lat, lon;</div>
<div class="line"><span class="keywordflow">while</span> (std::cin >> lat >> lon)</div>
<div class="line"> std::cout << g(lat, lon) << <span class="stringliteral">"\n"</span>;</div>
<div class="line">...</div>
</div><!-- fragment --><p>The first call to g(lat, lon) causes the data for the stencil points (4 points for bilinear interpolation and 12 for cubic interpolation) to be read and the interpolated value returned. A simple 0th-order caching scheme is provided by default, so that, if the second and subsequent points falls within the same grid cell, the data values are not reread from the file. This is adequate for most interactive use and also minimizes disk accesses for the case when a continuous track is being followed.</p>
<p>If a large quantity of geoid calculations are needed, the calculation can be sped up by preloading the data for a rectangular block with <a class="el" href="classGeographicLib_1_1Geoid.html#a52b5dc2d976796046aaeb8765e4a9c0f">Geoid::CacheArea</a> or the entire dataset with <a class="el" href="classGeographicLib_1_1Geoid.html#a482c6482d5ab4c5d661210327848170e">Geoid::CacheAll</a>. If the requested points lie within the cached area, the cached data values are used; otherwise the data is read from disk as before. Caching all the data is a reasonable choice for the 5' grids and coarser. Caching all the data for the 1' grid will require 0.5 GB of RAM and should only be used on systems with sufficient memory.</p>
<p>The use of caching does not affect the values returned. Because of the caching and the random file access, this class is <em>not</em> normally thread safe; i.e., a single instantiation cannot be safely used by multiple threads. If multiple threads need to calculate geoid heights, there are two alternatives:</p><ul>
<li>they should all construct thread-local instantiations.</li>
<li><a class="el" href="classGeographicLib_1_1Geoid.html" title="Looking up the height of the geoid above the ellipsoid. ">Geoid</a> should be constructed with <em>threadsafe</em> = true. This causes all the data to be read at the time of construction (and if this fails, an exception is thrown), the data file to be closed and the single-cell caching to be turned off. The resulting object may then be shared safely between threads.</li>
</ul>
<h1><a class="anchor" id="testgeoid"></a>
Test data for geoids</h1>
<p>A test set for the geoid models is available at</p><ul>
<li><a href="https://sf.net/projects/geographiclib/files/testdata/GeoidHeights.dat.gz">GeoidHeights.dat.gz</a></li>
</ul>
<p>This is about 11 MB (compressed). This test set consists of a set of 500000 geographic coordinates together with the corresponding geoid heights according to various earth gravity models.</p>
<p>Each line of the test set gives 6 space delimited numbers</p><ul>
<li>latitude (degrees, exact)</li>
<li>longitude (degrees, exact)</li>
<li>EGM84 height (meters, accurate to 1 μm)</li>
<li>EGM96 height (meters, accurate to 1 μm)</li>
<li>EGM2008 height (meters, accurate to 1 μm)</li>
</ul>
<p>The latitude and longitude are all multiples of 10<sup>−6</sup> deg and should be regarded as exact. The geoid heights are computed using the harmonic NGA synthesis programs, where the programs were compiled (with gfortran) and run under Linux. In the case of the EGM2008 program, a <code>SAVE</code> statement needed to be added to subroutine <code>latf</code>, in order for the program to compile correctly with a stack-based compiler. Similarly the EGM96 code requires a <code>SAVE</code> statement in subroutine <code>legfdn</code>.</p>
<center> Back to <a class="el" href="other.html">Implementations in other languages</a>. Forward to <a class="el" href="gravity.html">Gravity models</a>. Up to <a class="el" href="index.html#contents">Contents</a>. </center> </div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.9.1
</small></address>
</body>
</html>
|