How to calculate Height above the WGS-84 ellipsoid

Hi there,
I’m looking for some assistance on how to calculate a value for my Unreal Engine 5.4 project. I have a camera attached to an aircraft that flies around a level using Cesium and google 3d tiles. I need to calculate the distance between said camera and the WGS84 Ellipsoid. I work primarily in blueprints and was hoping there is some way to get this value.

Thanks

Hi @GU777, welcome to the community!

I suggest attaching a CesiumGlobeAnchor component to your camera. Then, you can query its height above the WGS84 ellipsoid using the Get Height Blueprint. Let us know if that works for you!


image

Thank you for the response! I imagine I need to make a socket on my camera to then attach this CesiumGlobeAnchor to?

I ran a test of attaching this component to the ThirdPerson_BP and when standing on google 3d tiles I got a height of 63.5. Is this expected? I thought it was be closer to 0 given that I’m standing on the ground

Hi @GU777,

I imagine I need to make a socket on my camera to then attach this CesiumGlobeAnchor to?

Sorry, I’m not sure what you mean by creating a socket on the camera. You would just have to attach the CesiumGlobeAnchorComponent under the Actor that you’re trying to maneuver. The DynamicPawn included with the plugin might be a good example.

I thought it was be closer to 0 given that I’m standing on the ground

The height above the WGS84 ellipsoid model is not necessarily (and often isn’t) equivalent to the height above Mean Sea Level, so it may seem unintuitively distant from the actual terrain.

If you would rather compute the height of an object above the actual terrain, then raycasting to the ground would be a better approach. It would help to know more about what you’re using this distance value for, in case there are better approaches :smile:


image

Thanks again for the response!
For more context, I am looking to output specific metadata using Unreal Engine and Cesium. I provided an image of what this metadata asks for. From my understanding this is asking for the height above this wgs84 ellipsoid of whatever the center of the camera is looking at. So I planned to send a line trace out of the center of the camera and get that lat long coordinate to then calculate height of that specific location.

If you think there is a better way to do this or need more information please let me know!

Thanks

Also, what should the “height” of the CesiumGeoreference actor be? Should I have it set to 0? Also curious if you know of a reliable way to test my output to see if Im getting the correct results or not.

Thanks!

From my understanding this is asking for the height above this wgs84 ellipsoid of whatever the center of the camera is looking at. So I planned to send a line trace out of the center of the camera and get that lat long coordinate to then calculate height of that specific location.

That approach makes sense to me.

You can do a line trace to get the Unreal (X,Y,Z) coordinates, and then convert that to Longitude / Latitude / Height (above the WGS84 ellipsoid) by calling TransformUnrealPositionToLongitudeLatitudeHeight on the CesiumGeoreference.

For a more accurate height, you can use the above to get the Longitude / Latitude, and then use the SampleHeightMostDetailed function to compute the exact tileset height above WGS84 at that longitude / latitude.

Also, what should the “height” of the CesiumGeoreference actor be? Should I have it set to 0? Also curious if you know of a reliable way to test my output to see if Im getting the correct results or not.

Whatever Longitude / Latitude / Height you specify on the CesiumGeoreference becomes the (0,0,0) (aka origin) of the Unreal Engine world. You can set it to whatever you like.