[Proj] Vertical and geocentric coordinate support in OGR/PROJ4
Mikael.Rittri at carmenta.com
Wed Aug 24 08:13:36 EST 2011
Thanks, Ben, for the information.
We have some customers who need to convert between
height-above-geoid and height-above-WGS84-ellipsoid,
but they don't need much accuracy: a couple of
meters error is okay. My advice has been to use
some representation of EGM2008, as the most detailed
global geoid model.
I would like to learn more about the maximal (or typical)
deviation between EGM2008 and other geoid models. For
Europe, my impression is that most of the national height
systems differ less than 0.5 m from the common European
height system EVRF2007 (see "Map Projections for Europe",
page 101, http://www.ec-gis.org/document.cfm?id=425&db=document ).
A curious exception is a difference of 2.3 m for
Belgium, which uses (or has used) a height system
based on mean low tide of some kind, instead of
mean sea level. I think Ireland has some similar
But I am not sure about the difference between EVRF2007
and EGM2008. I have looked at a few sample points where
there was a difference of up to about 0.4 m. I haven't
found any conversion method between EVRF2007 and EGM2008,
or any estimate of the differences. Does anyone know?
For the rest of the world, I am even less sure of
things. I have heard that the true mean sea level
can differ by a couple of meters from the geoid,
since mean sea level is not an equipotential surface
(due to variations in water temperature, salinity,
and whatever). But since national heights can be
measured from low tide - or maybe from something else -
I guess one can expect even larger deviations.
From: proj-bounces at lists.maptools.org [mailto:proj-bounces at lists.maptools.org] On Behalf Of Ben Discoe
Sent: den 24 augusti 2011 02:49
To: gdal-dev at lists.osgeo.org; proj at lists.maptools.org
Subject: [Proj] Vertical and geocentric coordinate support in OGR/PROJ4
The issues of geocentric CS and vertical CS are distinct, but they are related in an important way: Geocentric coordinates are not very useful to the GIS world unless they can be converted to orthometric ("sea level") heights, which involves a vertical CS.
Currently, the GDAL/OGR/PROJ4 stack has limited support for geocentric & vertical CS, but the limitation of what works and what doesn't is difficult to guess from the documentation. I'd like to contribute my understanding to date.
GDAL is actually doing quite a lot right, despite some major historical issues it has to deal with. As far as i can tell:
1. PROJ4 was never meant to handle vertical CS; as described on http://trac.osgeo.org/proj/wiki/VerticalDatums it's a late addition.
2. The EPSG codes are a messy, incomplete patchwork of 2D and 3D coordinate systems, in which vertical CS also seems to be an awkward, late addition.
3. OGC's WKT encoding (and hence OGR's) also wasn't quite designed to handle vertical CS; it can store a VERT_CS node, but that apparently isn't sufficient to actually define the transformation.
Understandably, as a result of the above history, the OGRSpatialReference implementation of VERT_DATUM nodes is somewhat awkward and ad-hoc.
The simplest way to create an OGRSpatialReference with a vertical CS is to use an import function, for example:
A. Working backwards from PROJ4:
srs.importFromProj4("+proj=longlat +datum=WGS84 +no_defs +geoidgrids=g2009conus.gtx");
B. Example of a compound, Paris-based CS from EPSG:
The first example produces an SRS that works (assuming you have g2009conus.gtx installed on your PROJ_LIB folder). The WKT has a section that looks like:
VERT_DATUM["North American Vertical Datum 1988",2005,
The PROJ4_GRIDS EXTENSION is what makes PROJ4 work.
The second example will not actually function. It creates WKT like this:
COMPD_CS["NTF (Paris) + NGF IGN69 height",
VERT_CS["NGF IGN69 height",
VERT_DATUM["Nivellement General de la France - IGN69",2005,
It lacks a PROJ4_GRIDS, because in the GDAL data file for composite CS, compdcs.csv, the entry is:
7400,"NTF (Paris) + NGF IGN69 height",4807,5720,1,0
This means the vertical CS is 5720, which appears in vertcs.csv as:
5720,NGF IGN69 height,5119,Nivellement General de la France - IGN69,9001,1,0,6499,,
Note there is no .gtx file present for 5720. There are in fact only 3 entries in vertcs.csv which contain a .gtx file, and hence only 3 that will produce valid results:
3855,EGM2008 geoid height,1027,EGM2008 geoid,9001,1,0,6499,9665,"egm08_25.gtx"
5703,NAVD88 height,5103,North American Vertical Datum 1988,9001,1,0,6499,9665,"g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx"
5773,EGM96 geoid height,5171,EGM96 geoid,9001,1,0,6499,9665,"egm96_15.gtx"
Of those three (3855, 5703, 5773), there is not a single entry in compdcs.csv which uses them. Hence, no compound CS set by EPSG code will actually work.
The third way to create an OGRSpatialReference with a vertical CS is like this:
srs4.SetVertCS("NAVD88 height", "North American Vertical Datum 1988");
srs4.SetExtension("VERT_DATUM", "PROJ4_GRIDS", "g2009conus.gtx");
AFAICT, the arguments to SetVertCS() are not a matter of functionality; they can be anything, but it seems good practice to put human-readable descriptions in there, ideally taken from a standard text like vertcs.csv. (This example is a bit confusing, because the vertical datum is named 1988, but the latest version of it is 2009). The main purpose of calling SetVertCS is to promote the CS to a compound CS with a VERT_DATUM node. The next call (SetExtension) can then decorate the VERT_DATUM with the 'extension' to make the SRS actually work, i.e. allow it to exportToProj4 correctly so that OGRCreateCoordinateTransformation will work correctly.
Here is a complete, functional example of converting a geocentric value to a geographic coordinate with orthometric height:
OGRSpatialReference srs1, srs2;
srs1.importFromEPSG(4978); // 4978 is the EPSG code for geocentric (ECEF)
srs2.SetVertCS("NAVD88 height", "North American Vertical Datum 1988");
srs2.SetExtension( "VERT_DATUM", "PROJ4_GRIDS", "g2009conus.gtx");
double x, y, z;
x = -2691744.9992481042; // A point on the ellipsoid
y = -4262401.8609118778;
z = 3894209.4515372305;
// ecef -> geoid
OGRCoordinateTransformation *oct = OGRCreateCoordinateTransformation(&srs1, &srs2);
oct->Transform(1, &x, &y, &z);
printf(" lon,lat,height %lf,%lf,%lf\n", x, y, z);
If it works, it prints the correct value:
If the VertCS/Extension is omitted, or if PROJ cannot find the .gtx file, or anything else goes wrong, you simply get the ellipsoidal height (close to 0.0).
In conclusion, although the vertical CS support in OGR/PROJ4 is a bit limited (and neither the limitations nor supported cases are documented), it can be made to work. Hopefully, this email will prove useful as documentation for anyone else needing to do this transformation.
As an aside, this whole discussion is purely about what works in the Open stack; i have absolutely no idea what sort of WKT (COMPD_CS / VERT_CS / VERT_DATUM) would work in the e.g. ESRI universe.
Proj mailing list
Proj at lists.maptools.org
More information about the Proj