# Convert geocentric distance from center of earth to geocentric altitude

**URL:** <https://discourse.julialang.org/t/convert-geocentric-distance-from-center-of-earth-to-geocentric-altitude/62419>\
**Category:** New to Julia\
**Tags:** package, geo\
**Created:** [June 5, 2021, 8:59am UTC](https://discourse.julialang.org/t/convert-geocentric-distance-from-center-of-earth-to-geocentric-altitude/62419 "2021-06-05T08:59:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sxd190026](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sxd190026/32/25250_2.png) [@sxd190026](https://discourse.julialang.org/u/sxd190026)\
**Post date:** [June 5, 2021, 8:59am UTC](https://discourse.julialang.org/t/convert-geocentric-distance-from-center-of-earth-to-geocentric-altitude/62419/1 "2021-06-05T08:59:21Z")

</div>

I was using Satellite Toolbox for using Jacchia Bowman 2008 atmospheric model. JB2008 model considers latitude, longitude and altitude in geocentric co-ordinate as input , but the satellite data I have is in Geodetic co-ordinate. There is a package in Satellite toolbox to convert the geodetic co-ordinates to geocentric co-ordinates, but that gives the height as a distance from center of earth. Can anybody tell me how can I convert geocentric distance from center of earth to geocentric altitude above the surface?

> for i = 1:len  
> A = GeodetictoGeocentric(deg2rad(Data.LAT[i]),Data.ALT[i]); #inputs are in geodetic cordinate  
> GLAT[i] = A[1]; #geocentric latitude  
> GALT[i] = A[2]; #geocentric distance  
> end  
> If anybody knows any workaround, that will also be appreciated.

---

<div class="post-metadata">

**Author:** ![pixelate](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@pixelate](https://discourse.julialang.org/u/pixelate)\
**Post date:** [June 5, 2021, 11:32am UTC](https://discourse.julialang.org/t/convert-geocentric-distance-from-center-of-earth-to-geocentric-altitude/62419/2 "2021-06-05T11:32:19Z")

</div>

My naive way of doing this would be to convert the geodetic to cartesian (ECEF) coordinates, scale them until they are on the Earth ellipsoid and the distance between the original and scaled coords would be the geocentric height above ellipsoid. But this involves writing a bit of code to do the scaling, so if you think this is a useful approach then I can paste the scaling code that I use (which uses the WGS 84 ellipsoid).

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [June 5, 2021, 8:35pm UTC](https://discourse.julialang.org/t/convert-geocentric-distance-from-center-of-earth-to-geocentric-altitude/62419/3 "2021-06-05T20:35:21Z")

</div>

Would it be alright to subtract the latitude-dependent Earth radius from the distance you obtained from the center of the Earth?

The Earth [geocentric radius](https://en.wikipedia.org/wiki/Earth_radius) at geodetic latitude φ is given by:

 ![geocentric_radius](https://global.discourse-cdn.com/julialang/original/3X/0/2/024f9ff5b1562e33d9c1d9b9a4a15d0024e4932f.png)

where `a = 6,378 km` is the equatorial radius, and `b = 6,357 km` is the polar radius.

---

<div class="post-metadata">

**Author:** ![sxd190026](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sxd190026/32/25250_2.png) [@sxd190026](https://discourse.julialang.org/u/sxd190026)\
**Post date:** [June 5, 2021, 10:10pm UTC](https://discourse.julialang.org/t/convert-geocentric-distance-from-center-of-earth-to-geocentric-altitude/62419/4 "2021-06-05T22:10:55Z")

</div>

Thanks for your answer rafael. Can you quote the source you got this equation from?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [June 5, 2021, 10:14pm UTC](https://discourse.julialang.org/t/convert-geocentric-distance-from-center-of-earth-to-geocentric-altitude/62419/5 "2021-06-05T22:14:30Z")

</div>

@sxd190026, updated link in post above.

---

<div class="post-metadata">

**Author:** ![sxd190026](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sxd190026/32/25250_2.png) [@sxd190026](https://discourse.julialang.org/u/sxd190026)\
**Post date:** [June 5, 2021, 10:27pm UTC](https://discourse.julialang.org/t/convert-geocentric-distance-from-center-of-earth-to-geocentric-altitude/62419/6 "2021-06-05T22:27:16Z")

</div>

thanks a lot rafael

---

<div class="post-metadata">

**Author:** ![danielmatz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielmatz/32/2285_2.png) [@danielmatz](https://discourse.julialang.org/u/danielmatz)\
**Post date:** [June 5, 2021, 11:26pm UTC](https://discourse.julialang.org/t/convert-geocentric-distance-from-center-of-earth-to-geocentric-altitude/62419/7 "2021-06-05T23:26:07Z")

</div>

Check out [ERFA.jl](https://github.com/JuliaAstro/ERFA.jl). It has a number of functions for doing these kinds of conversions.
