Get height of building relative to the ground

I am working on analyzing the elevation/height of buildings and various areas within Cesium by clicking on the map. The goal is to determine whether signals are being obstructed or passing through without interference. To achieve this, I am interacting with the map in 2D view, clicking on multiple locations that include buildings, parks, stadiums, and other structures.

Each time I click on the map, I record the coordinates and pass them to the sampleTerrainMostDetailed method to retrieve precise elevation data. Using this data, I intend to generate a distance vs. height graph to visualize the terrain and building heights accurately.

However, I am encountering an issue specifically with buildings and their surrounding areas. While terrain regions correctly return positive height values, large buildings are producing negative height values (e.g., -20 or -26 meters). Since signal towers are typically located within urban environments, I need accurate altitude data for buildings within the city rather than incorrect negative values.

To resolve this, I have experimented with various methods such as:

  • getPickRay
  • pickEllipsoid
  • pickPosition

Despite these attempts, I am still receiving negative height values for buildings. I need a reliable way to obtain the true height of buildings from the ground level rather than a negative offset.

Could you suggest an effective approach to ensure accurate elevation readings for buildings within city areas?

Hi @nigamam ,
Thanks for your post and welcome to the Cesium community.

Do you mind sharing an example of your setup using our sandcastle tool https://sandcastle.cesium.com/? This will make it easier for us to understand your setup - eg. which data layers your are using - and offer the best help.

Please let us know if you have any questions or need help setting things up.
Best,
Luke

Hello Luke_McKinstry ,

I have added some sample code in the below link. I have added some steps at the top to replicate my thoughts. Please check it once and let me know how i can get the height of any building or nearby area relative to the ground on map click

Thanks,
Amit

Hi @nigamam


I tested my sandcastle code for the One World Trade Center in New York City.
As you can see, it was measured as 547 m, and Google shows it as 541m.
I hope this can be helpful for you.
My Sandcastle here