# heightReference for position in CZML

**URL:** <https://community.cesium.com/t/heightreference-for-position-in-czml/5853>\
**Category:** CesiumJS\
**Created:** [July 25, 2017, 3:00pm UTC](https://community.cesium.com/t/heightreference-for-position-in-czml/5853 "2017-07-25T15:00:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bf1](https://avatars.discourse-cdn.com/v4/letter/b/e0b2c6/32.png) [@bf1](https://community.cesium.com/u/bf1)\
**Post date:** [July 25, 2017, 3:00pm UTC](https://community.cesium.com/t/heightreference-for-position-in-czml/5853/1 "2017-07-25T15:00:09Z")

</div>

Hi all,  
I have converted a GPX track to CZML. I have the path rendering properly but am unable to get the path to clamp to ground--it's roughly 30m below the surface but varying over time--probably because the GPS was changing its height fix over time. I attempted to resolve this by scrubbing the heights through a sampleTerrain function, which resulted in slightly different values, but still roughly 30m below the surface.

Is there a way to tell a position -\> cartographicDegrees to clamp itself to the terrain?

Thanks,  
Ben

---

<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:** [July 27, 2017, 7:11pm UTC](https://community.cesium.com/t/heightreference-for-position-in-czml/5853/2 "2017-07-27T19:11:28Z")

</div>

Hi Ben,

I think you can use the CZML property [HeighReference](https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/HeightReference) with the value  
CLAMP\_TO\_GROUND

``

Thanks,

Gabby

---

<div class="post-metadata">

**Author:** ![bf1](https://avatars.discourse-cdn.com/v4/letter/b/e0b2c6/32.png) [@bf1](https://community.cesium.com/u/bf1)\
**Post date:** [July 29, 2017, 4:35pm UTC](https://community.cesium.com/t/heightreference-for-position-in-czml/5853/3 "2017-07-29T16:35:01Z")

</div>

Thanks for the suggestion. I've given that a shot. Appears to have no effect.

"position": {  
&nbsp;&nbsp;&nbsp;&nbsp;"interpolationAlgorithm": "LAGRANGE",  
&nbsp;&nbsp;&nbsp;&nbsp;"interpolationDegree": 1,  
&nbsp;&nbsp;&nbsp;&nbsp;"epoch": "2017-06-05T16:49:14Z",  
&nbsp;&nbsp;&nbsp;&nbsp;"heightReference" : "CLAMP\_TO\_GROUND",  
&nbsp;&nbsp;&nbsp;&nbsp;"cartographicDegrees": [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-106.957785124,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;31.9563742261,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1218.13,

---

<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:** [August 1, 2017, 2:25pm UTC](https://community.cesium.com/t/heightreference-for-position-in-czml/5853/4 "2017-08-01T14:25:31Z")

</div>

Sorry I don’t have a czml example, but here’s the sandcastle demo for clamping to ground: [http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Ground%20Clamping.html&label=Showcases](http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Ground%20Clamping.html&label=Showcases), maybe the “Sample line positions” example is relevant?

---

<div class="post-metadata">

**Author:** ![bf1](https://avatars.discourse-cdn.com/v4/letter/b/e0b2c6/32.png) [@bf1](https://community.cesium.com/u/bf1)\
**Post date:** [August 4, 2017, 7:52pm UTC](https://community.cesium.com/t/heightreference-for-position-in-czml/5853/5 "2017-08-04T19:52:59Z")

</div>

Thank you for this help. My code to reset the heights of the path points wasn't using sampleTerrainMostDetailed. Now it is, and it's working like a charm. I really appreciate the help.

---

<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:** [August 7, 2017, 1:34pm UTC](https://community.cesium.com/t/heightreference-for-position-in-czml/5853/6 "2017-08-07T13:34:42Z")

</div>

Great! I’m glad to hear its working!
