I searched through previous questions & didn't find an answer to this one. At first glance it might look like a straightforward math question & off-topic, but it is related to a fleet management system and has a definite GIS flavo(u)r, so I hope that I can get some advice here.

My GPS device will give me Lat/Long, timestamp and current speed. I can query once a second if I want, although that seems like overkill.

The point is that it only gives me current speed and I want average speed. From two consecutive readings I can compute the distance travelled and the time taken, so I know the average speed for that segment, but what if I want the average speed for one hour?

  • do I just total the averages and average them?
  • I am unsure whether to include readings of zero speed in the count of the number of measurements (which shows how bad my math is). What if I only take 2 readings per hour & both times the vehicle is tationary at traffic lights, but otherwise it moves rather quickly?
    • I am not sure of what is a good sample frequency. I guess it might have to do with the anticipated average speed (e.g might differ between tracking combine harvesters & jet fighter planes)
  • I am concerned that oversampling might reduce accuracy

Is there a 'standard' algorithm for this sort of thing?

It might help if you can tell us what you want to use the average speed for. That will drive answers to "what do I do for zero speed events?" – BradHards

A good point. It's really just a feature for the end user, but different users might have different requirements. I will Google & see if I can find how other Fleet Management s/w does it.

What GPS device is it? most have current and average speed based from a location/waypoint. – Mapperz

This one does not, which is why I post the question. I have even asked the manufacturer who confirm their published API & indicate that they have no plans to introduce such a feature.

  • 2
    It might help if you can tell us what you want to use the average speed for. That will drive answers to "what do I do for zero speed events?"
    – BradHards
    Oct 10, 2013 at 2:14
  • 1
    What GPS device is it? most have current and average speed based from a location/waypoint.
    – Mapperz
    Oct 10, 2013 at 2:20

2 Answers 2


Mathematically speaking, Average speed is always the total distance divided by the total time. It is never the average of the speeds.

Now coming to practical aspects. As a user or driver, I will almost never be interested in average speed. What is far more interesting, is the time taken for the journey. So If I'm making a cross country journey of 1000 Km, How soon I'll reach my destination is important.

You as a developer has to work with the speeds and average speeds and tell me how long it will take. Given that a route will have variable traffic loads, different speed limits and so on, calculating the time taken is no trivial task.

What is usually done, is based on the instantaneous speed, the road network is broken down into regions of homogeneous or near homogeneous sections based on the speed. Based on these speeds, the estimated time can be calculated. Further more, whenever an unexpected situation occurs, this calculation is redone, thus giving a better estimation.

Now coming to the 'Zero speed' data. IMHO, this occurs in two cases. Firstly when you are on the road, stuck in traffic or a pileup; And Secondly when you are intentionally parked somewhere, be it a Gas station, or a Food Plaza by the Highway, or maybe doing your weekly shopping at the wallmart.

It is very difficult to distinguish between these two situation based on data from just one GPS device, but you could try to differentiate them by trying to see if the GPS locations fall on a road or not. The accuracy of this will depend on the region and area. For example, on a long distance trip, it's quite easy to distinguish the highway in the country side, but in heavy urban areas it's far more difficult.

You could always give the average speed (along with the maximum speed recorded) as a fun bonus, but it really doesn't have much utility


I'd get an average speed as the total of the distance travelled (so, not the start point to the end point, but the distance between each point and the next added to each other) divided by the total time travelling.

Don't average averages, that's a bit misleading. Work out a total average. Also store a max speed. The fun bit is working out what to do when not moving, i.e., if the engine is off or vehicle stopped, do you add those bits or pause the timer?

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.