[GIS] Get satellite lon/lat from NMEA sentence

latitude longitudenmeasatellite

I am working on a satellite tracking application where I can read NMEA data from file.

Here are the NMEA sentences I have:

$GPRMC,104426.591,A,5920.7019,N,01803.2893,E,0.117980,320.93,141204,,*0F 
$GPGGA,104427.591,5920.7009,N,01803.2938,E,1,05,3.3,78.2,M,23.2,M,0.0,0000*4A $GPGSA,A,3,05,24,17,30,02,,,,,,,,5.6,3.3,4.5*34 
$GPGSV,3,1,12,30,72,254,30,05,70,125,39,24,37,083,43,02,36,113,45*7B 
$GPGSV,3,2,12,04,32,059,34,01,27,307,00,14,26,256,00,06,24,219,00*7F 
$GPGSV,3,3,12,17,22,135,40,25,20,311,31,09,19,159,25,20,08,346,34*7C

And where I need help is I have to get the "satellite position" from the sentence in lon/lat.

I know the GSV data contains azimuth and elevation, but I don't now how to convert it to lon/lat coordinates.

Can somebody help me?

Best Answer

Azimuth and elevation gives you the direction of the satellite. Without knowing the distance you can't locate the satellite in 3 dimensions and hence work out what lat-long it is directly above.

There's some hairy-looking formulae here:

http://www.navipedia.net/index.php/GPS_and_Galileo_Satellite_Coordinates_Computation

that require the orbital parameters from the ephemeris data. This claims a very accurate (~metres) position. That formula seems to have been converted to C code here: https://www.colorado.edu/geography/gcraft/notes/gps/ephxyz.html

Assuming a spherical earth of radius 6371km and a circular orbit of altitude 20180km above the earth, the distance to a satellite is obtained from a triangle formed from the centre of the earth (C), the observer on the surface (P), and the satellite (S). We know two side lengths - PC is the earth radius, and CS is earth radius plus orbit altitude - and one angle internal to CPS which is the elevation plus 90 degrees. The triangle can be solved using standard textbook formula for the side lengths and angles, giving the distance to the satellite from the observer (PS).

The following diagram shows the triangle shaded in pink.

satellite orbit geometry

Getting the satellite's position in (x,y,z) space will involve a couple of 3d rotations to get the true direction from elevation and azimuth but should be straightforward.