Question about the altitude value around east coast when migrated from Google

By compare with Google Earth, the altitude, when using Cesium, I got around east coast are always negative values.
I found the demo on the website http://analyticalgraphicsinc.github.io/cesium-google-earth-examples/examples/groundAlt.html
On this page, the value is exactly from what I have with my code, but still they are negative ones. I am not sure if this is the problems with the altitude resource or Cesium is actually using different standard when computing the altitude. If, the answer is the latter, can I convert the negative values? Thanks.

Hello,

The accuracy of the results returned by viewer.scene.globe.pick depends on the level of the terrain tile that is loaded. When you’re zoomed out further away from the globe, the accuracy is less accurate than when you’re zoomed in really close to the terrain.

For consistent results, you can use the sampleTerrain function. Here’s an example that always queries the 12th level of terrain to get the height:

var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas, false);
handler.setInputAction(
function(click) {
var ray = viewer.camera.getPickRay(click.position);
var position = viewer.scene.globe.pick(ray, viewer.scene);
if (Cesium.defined(position)) {
var positionCartographic = Cesium.Ellipsoid.WGS84.cartesianToCartographic(position);

        Cesium.when(Cesium.sampleTerrain(viewer.terrainProvider, 12, [positionCartographic]),
        function(adjustedPositions){
            var span = document.getElementById('alt');
            span.textContent = adjustedPositions[0].height.toFixed(2);

        });
    }
},
Cesium.ScreenSpaceEventType.LEFT_CLICK

);

``

Best,

Hannah

Note that ge.ALTITUDE_ABSOLUTE in GE is MSL and the altitude in Cesium is WGS84 (the difference is called undulation). When transitioning code from GE to Cesium one needs to account for this difference. There are online calculators that will give you the Geoid height/undulation for a particular lat/lng.

  • Matt