what altitude is returned in sampleTerrainMostDetailed


I am using cesium to making some drone fly:

-> My Backend require MSL altitude.
-> Cesium use WSG84 altitude.

I found on internet that converting WSG84 to MSL require GEOID.

In My app I use Cesium World Terrain terrainProvider : Cesium.createWorldTerrain()

So I am full of different altitude everywhere.

I made a function to convert a GPS altitude in my backend, using a package to retrieve GEOID.
So I need Cesium to send a correct WSG(GPS) altitude to the backend


The problem I face is the following :

I draw points on a map, and I use createWorldTerrain. I want user to be able to change that altitude using above ground (cause none know the MSL of the place they are right ? ).

So what I am doing right now is the following

  • User Click on Map and I retrieve long/lat

  • I then call a function sampleTerrainMostDetailed to get the height of a point on the ground and return it.

  • const promise = Cesium.sampleTerrainMostDetailed(this.terrainProvider, [new Cesium.Cartographic(pos.longitude, pos.latitude, 0)]);

  • Cesium.when(promise, (updatedPositions) => {





  • ok, so with the above part of function, I have the altitude of a point above ground at 0m right ? since this updatedPositions[0].height since this is the altitude of a point above ground from TerrainProvider ?

  • I use this height as 0 and add my desired height let’s say 20m

  • I send this altitude to the backend,
    so let’s say I put a point at lat: 35, long:129

  • I call my function and get back 90m (so this should be the height of the ground in WSG (GPS) ?

  • I add my desired height above the ground so let’s say 20m

  • I add 90m (the ground) + 20m (the height) = 110(GPS) elevation for this point
    SO I send this elevation to my backend, but the result is wrong.

After checking all the backend code, the problem is that sampleTerrainMostDetailed do not return what I want.
GPS for my point should be 50m, but that function return me a 90m.


What is exactly the altitude returned from sampleTerrainMostDetailed ?

What is the altitude used from TerrainProvider ?

How Can I correctly get my WSG altitude above my Terrain Provider if not like this ?

Thank you.

Using :



I made some comparison of the data I get in meters.


669 | 705 | 49.421 | +36

52 | 88 | 37.162 | +36

51 | 36 | -15.992 | -15

0 | -86 | -98 | +86

So sampleTerrainMostDetailed should return

As is typical of the [Cartographic](https://cesium.com/docs/cesiumjs-ref-doc/Cartographic.html) type, the supplied height is a height above the reference ellipsoid (such as [Ellipsoid.WGS84](https://cesium.com/docs/cesiumjs-ref-doc/Ellipsoid.html#.WGS84))

So Cesium WorldTerrain Altitude return some WGS84, I believe I am then missing an additional conversion. from WGS84to GPS, to then convert GPS to MSL using GEOID. That is a lot of conversion.
I am searching online some library or tool to convert WGS84 to GPS. I thougt they were similar if not the same .

So After spending a lot of time, I still don’t find exactly the solution.

I am sure of this :

The *geoid height above the ellipsoid (N) *is the difference between the **ellipsoidal height **and orthometric (geoid) height.

N = He − Ho


*N = geoid height above the ellipsoidHe = ellipsoidal heightHo = orthometric (geoid) height *

**The problem is the same, I don’t know what the value height is from *sampleTerrainMostDetailed . If it’s an ellipsoidal height, like the description state, then the above formula should work when I use createWorldTerrain and the sampleTerrainMostDetailed It should provide me with the height of the ground above the ellipsoid, which I substract *Orthometric (geoid) **
height and I would correctly find the MSL N.
But the value from Cesium is way out of the value I would need so I am very confused with all those altitude with same name MSL = GeoID height above ellipsoid but MSL =! orthometric (geoid) height

The height returned in CesiumJS is height above the ellipsoid. You may find this blog post useful, especially the part under the title: “Altitude: Sea Level and the Ellipsoid” which talks about doing this computation:


You may also find this forum discussion helpful: https://groups.google.com/forum/#!searchin/cesium-dev/msl|sort:date/cesium-dev/DEqHCeLiqps/nQ5AWm3wCAAJ

Thanks Omar, I had see this before and that’s exactly what I wanted to apply.

Technically it would be just (Height in cesium above ellipsoid) - geoid = MSL.

I am sure my MSL and my GEOID are correct cause I compared them with tools online, but the height in cesium when using world terrain is not correct, it’s always + or - 50 meter away from what it should be (like in the little table I shown)

I take different point in different place on earth, get the height above ellipsoid in cesium, and compare to other altitude provider on the internet, I found correct value with the internet but rarely with Cesium

I wonder if it’s a precision problem or something else.


The elevation above the ellipsoid (ellipsoidal height) is the elevation above a mathematical model that approximates the shape of the earth.The current most common one is WGS84. These are the elevations that you’d get from a GPS.

Like we said in this case, the simple calculation of

Cesium (WSG84) - EGM2008 (Geoid) = MSL

Should work.

But when for example I make a point in Cesium in WorldTerrain at this position (that I convert ofc to radian before)

 longitude: 139.6072415,
 latitude: 35.7139224,
 height: 0

the sampleTerrainMostDetailed will return me

{ longitude: 2.4366093834476756, latitude: 0.6233236845608701, height: 86.8920731655 }

86.8920731655 meter above the ellipsoid is the altitude above the ellipsoid of the ground in world terrain at that position.

Now using https://www.unavco.org/software/geodetic-utilities/geoid-height-calculator/geoid-height :

I found Orthometric height (height above EGM96 geoid which approximates mean sea level): 49.7280731655 (meters)

But this is wrong, I know by real measure (it’s the place I do my testing) that this point the MSL is 14m.

I then use

https://www.daftlogic.com/sandbox-google-maps-find-altitude.htm Using the same coordinate and I found 52M

and when doing the calculation with this 52M I indeed find.

Orthometric height (height above EGM96 geoid which approximates mean sea level): 14.836 (meters)

So the value returned by sampleTerrainMostDetailed is wrong, or I am using it incorrectly. In that case I still don’t know why.

Actually it looks like I have to do the following to find MSL :

Cesium WSG84 - GeoidHeight = Altitude value of (https://www.daftlogic.com/sandbox-google-maps-find-altitude.htm)
Altitude - GeoidHeight = MSL value of (https://www.unavco.org/software/geodetic-utilities/geoid-height-calculator/geoid-height)

So I would have to do WSG84 - 2(Geoid) = MSL

I don’t know why, but I tried on many point on earth and it was pretty accurate of ± 3 meters

It indeed looks ok around the world when I do

WSG84 - 2(Geoid) = MSL


But I only do

WSG84 = MSL + Geoid


Like for the point above

POINT => {longitude: 139.6072415,latitude: 35.7139224, height: 0}
MEASURE => SampleTerrainMostDetailed (with createWorldTerrain) => 86.8920731655 meter above the ellipsoid
CALCULATE => 86.8920731655 - 2*(37.29716) = 12.2977531655
which is ± 3meter from my measure of 14m MSL

Same with all around the world.

if I only do a single GEOID I get the wrong value I showed above of 49.7280731655

Is there something I am doing wrongly ?

I found like

For anyone else following this, see additional discussion on GitHub here: https://github.com/AnalyticalGraphicsInc/cesium/issues/8414