I'm using L80 quectel GPS module. Which sends the NMEA protocol data string which has latitude, longitude, UTC time, knots, etc. We are going to use this GPS module in a vehicle. We have to calculate the distance travel by the vehicle using GPS. We have to show the total distance travel by the vehicle like an odometer. Is it possible to calculate total distance travelled by vehicles using "knots" value from a GPS? If it is possible, then how to calculate?


  • 2
    \$\begingroup\$ Do you have access to search engines such as google, or similar? \$\endgroup\$ – mkeith Oct 14 '15 at 4:33

Calculating distance from speed

As Peter Bennett has already written in his answer, you get the current speed in nautical miles from a GPS dataset. Multiplied by the time to the next GPS dataset, you get the distance traveled between the reception of the two datasets.

But: If you accelerate, the real speed increases, while your device thinks it's constant. So, the calculated distance is too low. The same applies when braking (calculated distance too high). A simple solution: Don't use the speed from the dataset, but the average speed between two datasets. If the acceleration is constant, the resulting distance is absolutely correct. If the acceleration is not constant, the result is still by far more precise.

Another BUT: What, if the GPS signal is lost for a longer period, like in a long tunnel? Let's say, the signal is gone for 6minutes. The last dataset states a speed of 50kt, the next of 10kt. How long is the distance? If there's a traffic jam in the tunnel and the driver had to brake down to 10kt right after loosing the GPS signal, the length is 10kt*0.1h=1nm. If he has to brake right before the next GPS signal, the length is 50kt*0.1h=5nm. Using average speed results in 3nm. What's true?

Calculating distance from coordinates

To solve this problems, it's best to not rely on speed at distinct times, but to calculate the distance from the coordinates. This still has some disadvantages, as the distance will be a bit too low for sharp curves (or tunnels with curves), but it's still better than the speed-approach.

The distance of a position to the equator is

$$y=H \cdot\langle lat\rangle$$

and the distance to the prime meridian is

$$x=H\cdot\langle lon\rangle\cdot \cos\langle lat\rangle$$

The angles are given in radian, not degree: \$\alpha[rad]=\frac{\pi}{180°}\cdot\alpha[°]\$

These formulas contain the distance to the center of the earth, which is $$H=R_{earth}+\langle altitude \ by \ GPS \rangle$$

The distance between two coordinates can then be calculated by


About \$R_{earth}\$:
As first approximation, the earth is a sphere with an average radius of 6371km, but it is more an ellipsoid with a 21km larger radius at the equator than at the poles. As result, distances between two coordinates near the equator are about 0.5% larger than at the poles. Mainly for correct altitudes, GPS usually uses a model of the earth called WGS84, which describes its ellipsoidal shape. The radius of the earth at a given latitude then is:

$$R_{earth}=\sqrt{(6356.7523km\cdot\sin\langle lat\rangle)^2+(6378.137km\cdot\cos\langle lat\rangle)^2}$$

Finally, this formula is only valid if the calculated distance is small compared to the size of the earth, so spherical effects can be neglected. (The shortest route from San Francisco, California to Rome, Italy is via Canada, Hudson bay, Greenland, UK, while my solution is US east coast, Portugal, Spain). If you are interested in calculating large distances, see Wikipedia about great-circle distances. But for your application, this solution is fine

| improve this answer | |
  • \$\begingroup\$ Hi @sweber. Thanks for the reply. Yes, loosing of GPS signal is a very big concern, the formula you gave will it work even GPS signal lost? \$\endgroup\$ – user6161 Oct 15 '15 at 6:19
  • 1
    \$\begingroup\$ How could it work without GPS signal? The formula calculates the distance (straight line) between two coordinates given by GPS. If there is no signal for some time, use the last and next valid signal. \$\endgroup\$ – sweber Oct 15 '15 at 8:27

One knot is one nautical mile per hour. A nautical mile is 1852 metres.

As a knot is a unit of speed, you have to determine the lenght of time the vehicle traveled at a particular speed to determine the distance travelled.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.