# How to satellite-to-site range given site coordinates and satellite ephemeris?

How can I calculate the distance of a position on earth to a satellite (for example a GPS satellite)? The satellites position is exactly known by its ephemeris data.

In a related question I've asked how to obtain those positions from the ephemeris: How to calculate position of GPS Satellite with transmitted ephemeris data?

• Depends on the ephemeris data. Could you post it? Where did you get it from? Oct 26, 2019 at 18:07
• Yeah, the data struct looks like this: rootOfA;deltaN;week;toc;af0;af1;af2;e;toe;omega;crs;cus;cuc;cis;cic;crc;i0;iDot;omega0;omegaDot;m0;tgd; it's transmitted by the satellite and i'm fetching the data via the ublox ubx-raw protocol Oct 26, 2019 at 22:58
• Could you please edit your question to add these details? What you've posted also looks like a header, please give actual numbers as well. And preferably, the source. Oct 26, 2019 at 23:11
• By "ephemeris data" do you mean the ephemeris that the GPS satellite transmits encoded in it's broadcast to Earth along with other data? Message format If you need very accurate results, you'll have to look carefully into things like coordinate frames and how time is treated. This won't be an easy task at all. I recommend you do some reading first, and then ask a more specific question when you find something specific that you need help with. This question may be considered too broad.
– uhoh
Oct 27, 2019 at 0:47
• ok, thx I wil do that Oct 27, 2019 at 9:54