[GIS] Measuring distance between two coordinate pairs taken from NMEA file

coordinatesdistancenmea

In order to measure momentary speed, first I need to measure the distance between two pairs of coordinates. That's where my lack of knowledge stops me.

I have example data in NMEA format:

$GPGGA,002246,3918.5986,N,11954.1140,W,1,08,2.3,2697.9,M,-22.4,M,,*4C
(...)
$GPGGA,002248,3918.5887,N,11954.1395,W,1,08,2.4,2696.5,M,-22.4,M,,*42

I figured out that data above gives me following information, needed to measure the distance:

    • Coordinates: 39 deg 18.5986' N, 119 deg 54.1140' W
    • Altitude (above sea level): 2697.9 m
    • Height of geoid above WGS84 elipsoid: -22.4 m
    • Coordinates: 39 deg 18.5887' N, 119 deg 54.1395' W
    • Altitude (above sea level): 2696.5 m
    • Height of geoid above WGS84 elipsoid: -22.4 m

Angular distance between this two points is: latitude -0,0099', longitude 0.0255'.
The difference between altitudes is -1,4 m.

And there I'm stuck. And my question is – how to measure the distance between those two points in (kilo)meters?

I think it's worth repeating that the distance would be very small, because it's needed to calculate a momentary speed. So I think the data emphasized above (the height of a geoide) could improve precision.

Best Answer

If your data is in a cartesian/rectangular coordinate system you could simply do 2 pythagorean calculations... where the first one would calculate the distance in XY plane, where a would be x1-x2 and b would be y1-y2. The second calculation would use the result from the first calculation as a and b would be z1-z2.

perhaps something like this

sqrt((sqrt((deltaX)^2+(deltaY)^2)))^2+(deltaZ)^2)