# Cesium for Unity calculates the terrain profile

**URL:** <https://community.cesium.com/t/cesium-for-unity-calculates-the-terrain-profile/25096>\
**Category:** Cesium for Unity\
**Created:** [June 30, 2023, 8:14am UTC](https://community.cesium.com/t/cesium-for-unity-calculates-the-terrain-profile/25096 "2023-06-30T08:14:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ljwxhkj](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ljwxhkj/32/14000_2.png) [@ljwxhkj](https://community.cesium.com/u/ljwxhkj)\
**Post date:** [June 30, 2023, 8:14am UTC](https://community.cesium.com/t/cesium-for-unity-calculates-the-terrain-profile/25096/1 "2023-06-30T08:14:54Z")

</div>

How to calculate terrain profiles in Cesium for Unity

 ![捕获](https://global.discourse-cdn.com/cesium/original/2X/0/08ec326efcd21e86284b78e4d36ae7b6c8cede5a.jpeg)

---

<div class="post-metadata">

**Author:** ![janine](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/janine/32/5135_2.png) [@janine](https://community.cesium.com/u/janine)\
**Post date:** [June 30, 2023, 2:03pm UTC](https://community.cesium.com/t/cesium-for-unity-calculates-the-terrain-profile/25096/2 "2023-06-30T14:03:10Z")

</div>

We don’t have an easy out-of-the-box way to do this, but here’s some thoughts with the tools we have.

You could try using `Physics.Raycast` to raycast towards the center of the earth, getting an intersection point in Unity coordinates. Then, use `CesiumGeoreference.TransformUnityPositionToEarthCenteredEarthFixed` and `EarthCenteredEarthFixedToLongitudeLatitudeHeight` to convert the Unity coordinates. The resulting height value is not a height above mean sea level – it’s the height above the WGS84 ellipsoid. To get the height above mean sea level, you’d need to do something along the lines of what Kevin describes in this post:

> [@The height of the sea is not 0](https://community.cesium.com/t/the-height-of-the-sea-is-not-0/14220/8):
>
> Hi @leielyq, Cesium for Unreal does not provide a way to set the sea height to 0, nor does it have a way to “pretend the world is flat” and ignore Earth curvature. But it should be possible to put your objects on the water surface without too much trouble. If your area of interest is relatively small, such that Earth curvature is negligible, you can probably get pretty close to “sea is at Z=0” with just a little bit of effort. The main trick is in figuring out the WGS84 height of mean sea leve…

---

<div class="post-metadata">

**Author:** ![ljwxhkj](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ljwxhkj/32/14000_2.png) [@ljwxhkj](https://community.cesium.com/u/ljwxhkj)\
**Post date:** [July 5, 2023, 2:14am UTC](https://community.cesium.com/t/cesium-for-unity-calculates-the-terrain-profile/25096/3 "2023-07-05T02:14:39Z")

</div>

I’ve fixed this issue, thank you very much
