In the evening, you open the fleet dashboard. A vehicle's track for the day is drawn on the map. In one spot, the vehicle seems to have driven right through the middle of an apartment building. In another, at a time when it was waiting at a red light, the system fired a "speeding" alert. And at the end of the day, the mileage in the report comes out higher than what the driver says.
Nothing is broken. This is exactly how raw GPS data behaves. In this post, we mapped the same drive with four different methods in a small virtual city we built ourselves. Then we calculated, meter by meter, how accurately each one showed the vehicle. We'll try to explain how a vehicle tracking system turns the dots that land on the screen into a real route.
The Same 14-Minute Drive, Four Different Maps
The sample data is synthetic. We drew a 1.6 x 1.2 km neighborhood. Streets intersect every 200 meters, there's a district of tall buildings in the middle, and to the north there's a highway with a frontage road running parallel to it 12 meters away. The vehicle drives a 4.56 km route. It goes no faster than 40 km/h, waits at two red lights, and sits parked for 3 minutes at the start and 2 minutes at the end. The whole drive is 14 minutes, and the device sends a position every second.
We built the GPS error from three parts. The first is a slow drift: the point stays a few meters off the true position, on the same side, for about half a minute. The second is a small jitter that changes every second. The third is sudden jumps that occur only among the tall buildings: every second, there's a 4 percent chance the point leaps 30 to 70 meters away and stays there for 1 to 3 seconds. In open areas, this model's average error is 4.4 meters. Around the frontage road the drift is a bit larger, 6.3 meters on average. Among the buildings it rises to 14.9 meters.
| Method | Average deviation | Points off the vehicle's road | Distance counted (actual 4.56 km) | Phantom speeding alerts |
|---|---|---|---|---|
| Raw GPS | 6.5 m | 35% | 6.60 km | 77 |
| Snap each point to the nearest road | 4.6 m | 11% | 6.20 km | 76 |
| Kalman filter | 6.4 m | 33% | 5.38 km | 18 |
| Kalman filter and map matching | 3.7 m | 4% | 4.82 km | 10 |
A "point off the road" means a position that falls more than 5 meters away from the road the vehicle was actually on. These are the points that show up on the map inside a building, on the sidewalk, or on a side street. "Phantom speeding alerts" shows how many separate times the speed calculated from the distance between two positions exceeded the 50 km/h limit. The vehicle never went over 40 km/h at any point, so every one of these alerts is false.
Raw GPS makes it look as if the vehicle traveled 6.60 km instead of 4.56, which is 45 percent too much. In one of the sudden jumps, the speed between two points comes out at 239 km/h. Snapping to the nearest road makes the map look cleaner but barely fixes the mileage, because the points keep jumping back and forth between roads. The Kalman filter reduces the jitter and the alerts, but it can't get the points out of the buildings. In the last row we use both together: the deviation drops to 3.7 meters, off-road points to 4 percent, and the mileage error to 6 percent.
These results come from a single random trial. When we repeated the same calculation 30 times with different random errors, the raw track counted between 6.10 and 6.85 km every time. The method in the last row stayed between 4.58 and 4.96 km.

Why Is It Hard?
A GPS receiver calculates its position by measuring how long signals from satellites take to arrive. Under an open sky, this works very well. According to the U.S. government's official GPS website, GPS-enabled smartphones are typically accurate to within a 4.9-meter radius under open sky. The same source also says this accuracy degrades near buildings, bridges, and trees.
You can compare the cause to the echo you hear when you shout in a valley. Among tall buildings, the satellite signal sometimes reaches the receiver not directly but by bouncing off the glass of the building across the street. Because the bounced signal travels a longer path, the receiver thinks it's somewhere other than where it actually is. This effect is called "multipath." That's also why streets lined on both sides by tall buildings are called "urban canyons."
The truly surprising number, though, comes from a vehicle that isn't moving at all. In our example, the vehicle sits parked for 3 minutes before the drive starts. In those three minutes, the raw GPS track accumulates 462 meters of distance. While the point jitters in place, every small jump gets added up as "distance." Across all 30 repetitions, this number came out between 474 and 561 meters. For a service vehicle that waits for long periods several times a day, that means kilometers that were never driven.
Step One: A Smart Average of Prediction and Measurement
Imagine driving on a foggy road. You can barely see the road signs, but you know your speed and direction. You can estimate where you'll be one second from now. When a sign appears through the fog, you correct your estimate accordingly. If the sign is blurry, you correct a little; if it's clear, you correct a lot.
The method Rudolf Kalman published in 1960 does this with math. Every second there are two things: a prediction based on the vehicle's speed and heading, and the position the GPS reports. The filter takes a weighted average of the two. It sets the weights itself, based on how much each one can be trusted. With our settings, the filter settled into equilibrium within ten seconds and began giving 43 percent weight to the measurement and 57 percent to the prediction.

The filter really does smooth out the jitter. The 462 meters of phantom distance while parked drops to 181 meters, and phantom speeding alerts drop from 77 to 18. But the average deviation in the table barely changes. That's because the filter doesn't know the map. If the point drifts into a building for half a minute, the filter follows that drift too, smoothly and convincingly. The second step, which solves the problem, is to take into account where the roads are.
Step Two: Match the Journey, Not the Points
The first solution that comes to mind is to move each point to the nearest road. The 12 meters between the frontage road and the highway show why this idea doesn't work. The moment the error drifts a few meters toward the highway, the point jumps onto the highway, then jumps back a second later. In reality, the vehicle can only get onto the highway via a ramp a few hundred meters away. Averaged over 30 repetitions, 17 percent of the points from the vehicle driving on the frontage road were snapped onto the highway. In one bad trial, that rate rose to 54 percent.
Map matching changes the question. Instead of "which road is this point closest to?", it asks "which chain of roads best explains all of these points together?" For each point, a few nearby roads are selected as candidates, and each candidate is scored with two questions:
- How close is the point to this road? A closer candidate is more likely. The typical GPS error is used as the yardstick here.
- Can you get here from the previous candidate with a reasonable drive? If two points are 10 meters apart as the crow flies but 400 meters apart on the road network, that transition isn't very likely. Going from the frontage road to the highway in one second is exactly that kind of transition.
This structure is called a "hidden Markov model." What's "hidden" is which road the vehicle is actually on. We can't see it directly; we only see the GPS points. Instead of trying every possible chain of roads one by one, it uses the Viterbi algorithm, which at each step keeps the best story so far for each candidate. The algorithm was developed in 1967 to decode digital signals coming over a noisy line. The classic work that applied this idea to map matching is the 2009 paper by Paul Newson and John Krumm of Microsoft. We, too, estimated settings such as the error margin from the data using the method in that paper, and we skipped consecutive points closer than 14 meters to each other. As a result, 244 of the 846 points were used.

Four Things That Break It in Real Life
1. Mileage and Fuel Reports Get Inflated by Jitter and Shrink With Sparse Data
The mileage report is usually derived by adding up the distances between points. With dense data, jitter inflates the mileage. With sparse data, on the other hand, a straight line is drawn between two points, so corners get cut and the mileage comes out short. We sampled the same drive at different intervals:
| 1 s | 5 s | 15 s | 30 s | 60 s | |
|---|---|---|---|---|---|
| Daily position messages per vehicle | 86,400 | 17,280 | 5,760 | 2,880 | 1,440 |
| Distance counted by raw GPS | 6.60 km | 5.07 km | 4.52 km | 4.38 km | 3.79 km |
| Distance counted by map matching | 4.82 km | 4.79 km | 4.57 km | 4.57 km | 4.55 km |
The actual distance is 4.56 km in every column. Raw GPS overcounts by 45 percent at 1 second and undercounts by 17 percent at 60 seconds. Map matching, because it fills in the gap between two points along the real road network, stays accurate even with sparse data. For a business that ties fuel consumption or driver bonuses to mileage, this difference translates directly into money.
2. Phantom Alerts: Speeding and "Vehicle Moved"
Calculating speed from the distance between two positions turns every jump into a burst of speed. That's how the 239 km/h in our example came about. Most GPS receivers also send a separate ground speed value alongside the position. Among the standard NMEA sentences, RMC has a dedicated field for this. Alerts should be based on this value or on the matched route.
A stationary vehicle is a separate headache. The reason our best method counted 4.82 km instead of 4.56 is largely a single moment: the vehicle waits 30 seconds at a red light among the tall buildings, the points jump around, and the algorithm mistakes some of them for movement. Of the 255 extra meters counted, 176 accumulate in that half minute. In practice, making the "vehicle is stationary" decision separately, using ignition status, the device's motion sensor, or ground speed, closes this gap.
3. Frequent Positions, or Battery and Data?
Sending a position every second seems like the most accurate option at first glance. But the first row of the table shows that between 1 second and 30 seconds there's a 30-fold difference in daily messages. Every message means device battery, mobile data, and server and database load. What's more, after map matching, mileage accuracy at 15 and 30 seconds came out better than at 1 second, because with sparse data, jitter doesn't add up. Newson and Krumm also report that on their own real driving data, the route error stayed at 0.11 percent even when the sampling interval was increased to 30 seconds. The right interval depends on the type of work. Live courier tracking needs frequent data; a daily mileage report often doesn't. The device can also be configured to send sparsely when the vehicle is stopped and frequently when it's moving.
4. Tunnels, Parking Garages, and Roads That Aren't on the Map
In tunnels and enclosed parking garages, the signal cuts out completely. The first few points that arrive on exit are usually wrong too. Map matching can fill this gap with the most plausible route over the road network, but the longer the gap, the more possible routes there are. That's why a good system splits the track into separate segments over a long gap and displays the estimated part differently on screen.
Roads that aren't on the map are another trap. If a newly opened street, a factory site, or the inside of a parking lot isn't on the map, the algorithm forces the vehicle onto the nearest familiar road. Newson and Krumm also list roads not marked on the map and parking structures as one reason points end up with no candidates. Map matching is only as accurate as the map you have.
Does Every Business Need This?
No. If all you want is to answer "where is the vehicle right now?", raw GPS is usually enough. An error of a few meters doesn't change which neighborhood you'll find the vehicle in. Map matching becomes necessary where the numbers turn into a decision or money: mileage-based billing, fuel monitoring, driver scoring, route compliance, and speeding reports. If you operate in a city with lots of parallel roads and tall buildings, this need shows up sooner.
There's also the cost side. Map matching requires an up-to-date road map and a server that queries it. For most fleets, running it in batches when a trip ends or every few minutes, rather than every time a position arrives, is enough. On our vehicle tracking system software page, we explain how this data flows from the device to the report.
For developers: sending a request to an off-the-shelf matching engine
The Match service of the open-source OSRM does this over HTTP. Coordinates are given in longitude,latitude order. timestamps is Unix time in seconds, and radiuses is the estimated GPS error of each point in meters (default 5 m). Increasing this value among tall buildings gives the matching more slack.
curl "https://osrm.sirketiniz.com/match/v1/driving/28.97840,41.00820;28.97905,41.00861;28.98012,41.00903?timestamps=1762765200;1762765205;1762765210&radiuses=8;8;25&gaps=split&tidy=true&overview=full&geometries=geojson"
In the tracepoints array of the response, outlier points that couldn't be matched come back as null. For each segment in matchings, a confidence value between 0 and 1 is returned. Tracks with large gaps in their timestamps are split into separate segments.
Sources
- GPS.gov, "GPS Accuracy": gps.gov/gps-accuracy
- P. Newson, J. Krumm, "Hidden Markov Map Matching Through Noise and Sparseness", ACM SIGSPATIAL GIS 2009: microsoft.com/en-us/research
- R. E. Kalman, "A New Approach to Linear Filtering and Prediction Problems", Journal of Basic Engineering 82(1), 1960: doi.org/10.1115/1.3662552
- A. J. Viterbi, "Error Bounds for Convolutional Codes and an Asymptotically Optimum Decoding Algorithm", IEEE Transactions on Information Theory 13(2), 1967: ieeexplore.ieee.org
- OSRM HTTP API documentation, Match service: project-osrm.org/docs
- gpsd, "NMEA Revealed" (RMC sentence): gpsd.gitlab.io/gpsd/NMEA.html
Note: The city, route, and GPS errors in this post are synthetic; the error model was built only for this example. All figures in the tables and animations were calculated on this synthetic data and do not represent any real vehicle or customer operation. The open-sky accuracy figure and Newson and Krumm's 0.11 percent result are taken from the publications listed in the sources.
Cover photo: MagicTV / Pixabay