# Mapping HeightReference.RELATIVE\_TO\_GROUND to true height

**URL:** <https://community.cesium.com/t/mapping-heightreference-relative-to-ground-to-true-height/35965>\
**Category:** CesiumJS\
**Created:** [October 22, 2024, 11:32am UTC](https://community.cesium.com/t/mapping-heightreference-relative-to-ground-to-true-height/35965 "2024-10-22T11:32:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_K](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/christian_k/32/26217_2.png) [@Christian\_K](https://community.cesium.com/u/Christian_K)\
**Post date:** [October 22, 2024, 11:32am UTC](https://community.cesium.com/t/mapping-heightreference-relative-to-ground-to-true-height/35965/1 "2024-10-22T11:32:09Z")

</div>

I am building a drone tracker which updates the drone’s position in realtime. I use “heightReference: HeightReference.RELATIVE\_TO\_GROUND” on my drone model, to visualise its actual position above ground.

I wish to draw a line which shows a “power output” for a specific coordinate on its flight path. But the flight path appears way below the drone due to “HeightReference.RELATIVE\_TO\_GROUND”.

Is there a way to get my entity’s actual current position, so i can draw the line corresponding to the drone’s real position?

 ![chrome_jL1kxj79dT](https://global.discourse-cdn.com/cesium/original/3X/c/c/ccc92c516f0d3f769aa9472374459f6235348ad4.png)  
 ![chrome_JL7fqDLov2](https://global.discourse-cdn.com/cesium/original/3X/b/3/b37fbdac408ea95a3b62a62be1f628b8360d0e26.png)

i draw the flight path as such:  
update(lon: number, lat: number, alt: number, color: Color) {  
const newPosition = Cartesian3.fromDegrees(lon, lat, alt);

```
    // Add the new position and color to the arrays
    this.positions.push(newPosition);
    this.colors.push(color);

    // If the primitive exists, remove it before creating the updated one
    if (this.primitive) {
        this.viewer.scene.primitives.remove(this.primitive);
    }

    // Create a new primitive with updated geometry
    if (this.positions.length > 1) {
        this.createPrimitive();
    }
}

```

private createPrimitive() {  
if (!this.viewer) {  
return  
}  
const geometry = new PolylineGeometry({  
positions: this.positions,  
vertexFormat: PolylineColorAppearance.VERTEX\_FORMAT,  
colors: this.colors,  
colorsPerVertex: true,  
width: 5  
});

```
    const geometryInstance = new GeometryInstance({
        geometry: geometry,
    });

    this.primitive = new Primitive({
        geometryInstances: geometryInstance,
        appearance: new PolylineColorAppearance(),
        asynchronous: false
    });

    this.viewer.scene.primitives.add(this.primitive);
}

```

And i give the exact same coordinates when moving the drone as when updating the flight path:  
this.moveDrone(lon, lat, alt);  
const color = this.getColorForPower(power);  
this.flightPath.update(lon, lat, alt, color);

---

<div class="post-metadata">

**Author:** ![Christian\_K](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/christian_k/32/26217_2.png) [@Christian\_K](https://community.cesium.com/u/Christian_K)\
**Post date:** [October 23, 2024, 12:10pm UTC](https://community.cesium.com/t/mapping-heightreference-relative-to-ground-to-true-height/35965/2 "2024-10-23T12:10:48Z")

</div>

Just a quick update to my own post:

What i ended up doing was using Cesium.sampleTerrainMostDetailed for the given longitude and latitude and then adding the resulting height to my altitude, which works!
