# Terrain Exaggeration Issue

**URL:** <https://community.cesium.com/t/terrain-exaggeration-issue/6443>\
**Category:** CesiumJS\
**Created:** [January 9, 2018, 8:29pm UTC](https://community.cesium.com/t/terrain-exaggeration-issue/6443 "2018-01-09T20:29:55Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Omlor](https://avatars.discourse-cdn.com/v4/letter/c/ecc23a/32.png) [@Chris\_Omlor](https://community.cesium.com/u/Chris_Omlor)\
**Post date:** [January 9, 2018, 8:29pm UTC](https://community.cesium.com/t/terrain-exaggeration-issue/6443/1 "2018-01-09T20:29:55Z")

</div>

1. A concise explanation of the problem you're experiencing.  
I am using global DEM from USGS. I have a globe setup and terrain exaggeration is "working". I am placing pins on the map using actual elevations from USGS.

If i set the terrain exaggeration value to 0[Flat Map] and offset the elevation so it is exactly 0, my pins lay directly on the surface like they should. The problem is that negative elevations are inside the planet. With exaggeration of 0[Flat Map] this is expected. When i set terrain exaggeration to 1 the terrain is exaggerated. The point is now inside the planet. The point is at 0 elevation which is actually about 4km above the surface due to this point being 4km below "sea level".

How does cesium compute terrain exaggeration. Do it read elevation data from the DEM?

4. The Cesium version you're using, your operating system and browser.  
Cesium Version: 1.24  
OS: Ubuntu 16.04 & OSX High Sierra  
Web Browsers: Chrome(Current Stable), FireFox(Current Stable), and Safari.

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [January 11, 2018, 9:35pm UTC](https://community.cesium.com/t/terrain-exaggeration-issue/6443/2 "2018-01-11T21:35:48Z")

</div>

Hi there,

Here’s t[he code changes](https://github.com/AnalyticalGraphicsInc/cesium/pull/3200/files) where terrain exaggeration was implemented. It’s based on the height of the provided quantizedMesh or heightmap provided. If you could provide a [Sandcastle](https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/index.html?src=Hello%20World.html&label=Showcases) example showing the problem, we can take a look and see if there is a potential error with how we are handling points in the case of terrain exaggeration.

Thanks,

Gabby

---

<div class="post-metadata">

**Author:** ![Chris\_Omlor](https://avatars.discourse-cdn.com/v4/letter/c/ecc23a/32.png) [@Chris\_Omlor](https://community.cesium.com/u/Chris_Omlor)\
**Post date:** [January 29, 2018, 11:19pm UTC](https://community.cesium.com/t/terrain-exaggeration-issue/6443/3 "2018-01-29T23:19:53Z")

</div>

Sorry it took so long to respond. I don’t have a sandcastle example as I am not working inside sandcastle. I do have screen shots and a screen capture video showing what happens if that is helpful to you.

---

<div class="post-metadata">

**Author:** ![Chris\_Omlor](https://avatars.discourse-cdn.com/v4/letter/c/ecc23a/32.png) [@Chris\_Omlor](https://community.cesium.com/u/Chris_Omlor)\
**Post date:** [January 30, 2018, 12:28am UTC](https://community.cesium.com/t/terrain-exaggeration-issue/6443/4 "2018-01-30T00:28:39Z")

</div>

Here is a google drive share that shows the problem with screen shots and screen capture video. In the video I have debug console showing. This shows the actual elevation of the point I clicked on the map. I place the pin 5000 meters above the point clicked. So the point i clicked is approximately -4100 meters and i place the pin at 5000 meters above that. So my pin is actually about 900 meters above sea level on this video. As you will see the pin gets absorbed inside the planet when terrain exaggeration is turned on. This is the source data used for basemap [https://astrogeology.usgs.gov/search/details/Mars/Viking/MDIM21/Mars\_Viking\_MDIM21\_ClrMosaic\_global\_232m/cub](https://astrogeology.usgs.gov/search/details/Mars/Viking/MDIM21/Mars_Viking_MDIM21_ClrMosaic_global_232m/cub).

I am also curious as to what projection system Cesium expects in it’s DEM’s?

Google Drive Share: [https://drive.google.com/open?id=1poLxN8UCdGrXLS8FZRwHKt5M0i1UcFj2](https://drive.google.com/open?id=1poLxN8UCdGrXLS8FZRwHKt5M0i1UcFj2)

Thank you

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [January 31, 2018, 9:40pm UTC](https://community.cesium.com/t/terrain-exaggeration-issue/6443/5 "2018-01-31T21:40:40Z")

</div>

Hi Chris,

The Sandcastle example isn’t as necessary as a code snippet, I just need to see how you are adding your pins so we can figure out what exactly what’s going on here.

Cesium doesn’t use the DEM files directly, they must be converted to **heightmap** or **quantized-mesh** formats: [https://cesiumjs.org/data-and-assets/terrain/formats/](https://cesiumjs.org/data-and-assets/terrain/formats/)

Thanks,

Gabby

---

<div class="post-metadata">

**Author:** ![Chris\_Omlor](https://avatars.discourse-cdn.com/v4/letter/c/ecc23a/32.png) [@Chris\_Omlor](https://community.cesium.com/u/Chris_Omlor)\
**Post date:** [January 31, 2018, 11:18pm UTC](https://community.cesium.com/t/terrain-exaggeration-issue/6443/6 "2018-01-31T23:18:40Z")

</div>

Ok. Here is a code snippet of adding a pin to the map.  
entity = kernel.cesiumWidgetObj.entities.add({

id: pointdata.counter.toFixed(0),

name : ‘Pin’,

position : Cartesian3.fromDegrees(pointdata.lon, pointdata.lat, pointdata.s\_alt),

billboard : {

image : this.SELECTED\_PIN,

verticalOrigin : Cesium.VerticalOrigin.TOP

}

});

pointdata is a data structure containing the information for a given point. lon and lat are obviously latitude and longitude location of the point. s\_alt is the elevation of the point + 5000 meters. The elevation of the point is gathered from a rest api call that gets the scientifically accurate elevation of that lat/lon position.

Here is a definition of the data structure holding all the information:

var pointdata = {

pid: counter,

lon: lon,

lat: lat,

s\_alt: altitude + 5000,

heading: heading,

pitch: pitch,

roll: roll,

};

Thank you for your help. I appreciate it.

---

<div class="post-metadata">

**Author:** ![Chris\_Omlor](https://avatars.discourse-cdn.com/v4/letter/c/ecc23a/32.png) [@Chris\_Omlor](https://community.cesium.com/u/Chris_Omlor)\
**Post date:** [February 22, 2018, 7:48pm UTC](https://community.cesium.com/t/terrain-exaggeration-issue/6443/7 "2018-02-22T19:48:19Z")

</div>

I'm just checking in. Any thoughts on this? Am I doing something incorrectly?

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [February 27, 2018, 10:36pm UTC](https://community.cesium.com/t/terrain-exaggeration-issue/6443/8 "2018-02-27T22:36:25Z")

</div>

Hi Chris,

Apologies for the delay! Is there a particular reason you are using the predetermined **s\_alt** value? If not, I would recommend setting the [Billboard.heightReference](https://cesiumjs.org/Cesium/Build/Documentation/Billboard.html#heightReference) property to [HeightReference.CLAMP\_TO\_GROUND](https://cesiumjs.org/Cesium/Build/Documentation/HeightReference.html#.CLAMP_TO_GROUND). It will clamp the billboard to terrain without having to sample the height value yourself. Let me know if that doesn’t work for your purposes.

Thanks,

Gabby

---

<div class="post-metadata">

**Author:** ![Chris\_Omlor](https://avatars.discourse-cdn.com/v4/letter/c/ecc23a/32.png) [@Chris\_Omlor](https://community.cesium.com/u/Chris_Omlor)\
**Post date:** [February 27, 2018, 10:51pm UTC](https://community.cesium.com/t/terrain-exaggeration-issue/6443/9 "2018-02-27T22:51:40Z")

</div>

Thank you for that. I must have missing the CLAMP\_TO\_GROUND property in the documentation. I will give that a try and see how it works out.

---

<div class="post-metadata">

**Author:** ![Chris\_Omlor](https://avatars.discourse-cdn.com/v4/letter/c/ecc23a/32.png) [@Chris\_Omlor](https://community.cesium.com/u/Chris_Omlor)\
**Post date:** [February 27, 2018, 11:19pm UTC](https://community.cesium.com/t/terrain-exaggeration-issue/6443/10 "2018-02-27T23:19:17Z")

</div>

So my pins are now working properly. I needed the RELATIVE\_TO\_GROUND property. This allowed my altitude of the pin to float in space above the ground as I wanted it.

Is there a way for me to do this with a poly line as well? There is a poly line arrow that connects each of those pins together. They are still being set below the surface and I need those to be “attached" to the bottom of the pins.

Thank you

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [February 28, 2018, 4:31pm UTC](https://community.cesium.com/t/terrain-exaggeration-issue/6443/11 "2018-02-28T16:31:56Z")

</div>

Awesome, glad that works!

Polylines cannot _yet_ be draped on terrain, but we are currently working on supporting that feature. Keep an eye on [#2172](https://github.com/AnalyticalGraphicsInc/cesium/issues/2172) in GitHub.

---

<div class="post-metadata">

**Author:** ![Chris\_Omlor](https://avatars.discourse-cdn.com/v4/letter/c/ecc23a/32.png) [@Chris\_Omlor](https://community.cesium.com/u/Chris_Omlor)\
**Post date:** [February 28, 2018, 5:34pm UTC](https://community.cesium.com/t/terrain-exaggeration-issue/6443/12 "2018-02-28T17:34:06Z")

</div>

Awesome. Thank you for your help.
