API to query elevation data

I am looking for an easy to query within a unity script the following:

  • input: latitude, longitude geo data
  • output: elevation

ChatGPT showed me an example with “CesiumGlobe” and “TerrainProvider.GetElevationAtLocation” but this doesn’t seem to be available in the current version and I can’t find anything about it.
From the objects & API I have in unity available the maximum available detail level seems to be the 3D Tile but not a specific point.

@Karim_Panda Thanks for the question! I believe you’re looking for SampleHeightMostDetailed. You can pass in your long/lat values and obtain from them the height of each point above the WGS84 ellipsoid.

Note that the height above ellipsoid might not be what you’re looking for. People often refer to elevation based on sea level, not based on the ellipsoid. You can read more about the difference between ellipsoidal height and Mean Sea Level (MSL) in our geospatial guide. To convert between ellipsoidal height and MSL, we offer support for the Earth Gravitational Model 1996 grid, which can be used to obtain the difference between the ellipsoidal surface and the EGM96 approximation of mean sea level. This, combined with the output from SampleHeightMostDetailed, can tell you roughly the height above sea level of a point on the globe.

Unfortunately, the EarthGravitationalModel1996Grid class is not currently connected up to the C# side for use in Unity. However, this wouldn’t be a very complicated task if you’re interested in submitting it as a community contribution to Cesium for Unity!

Thank you for the quick reply!
I will try that and give you feedback.