A production-ready solution for dealing with GPS inaccuracies

The problem of GPS being non ideally accurate is not new, as well as the “snap-to-road” functionality that mainly does the matching of GPS traces to roads. Most of the projects that tend to have this problem are solving this either through Google Maps Snap to Roads API or OSRM Match Service API. But I’m going to show you the way I had taken and didn’t regret anything.

Problem

Primarily my problem was to calculate the distances of travelling per day and month done by cars. What’s also important is that I was trying to build a production solution that could do that every day, so not only a research part.

Since I had multiple already preprocessed GPS traces in GeoJSON, I created a Python script that calculates distances using geopy.distance.geodesic function and looping over the whole trip’s geopoints. By my rough estimation, this approach sometimes had an error rate of more than 30%, which is actually horrible. Let me explain why.

As shown in the map below, sometimes GPS traces are not exactly accurate. Obviously, the driver was using the road path here, but the geopoints that we got from the GPS are placed near the road, not on it.

#pandas #gps #geospatial #valhalla #snap-to-road

Map Matching Done Right using Valhalla’s Meili
2.80 GEEK