# Correction of GPS-Track, snap to road (line, network)

Problem as shown in the image: I like to correct the GPS track (orange) to the right road (black). In a network of roads it is difficult to snap to the right path - for human it's obvious which one is the right - how can we compute?

Until now I tried to find a solution in QGIS: A. in QGIS

2. clip track
3. extract vertices
5. points to path
6. snap to road -> corners are often cropped

I also tried to smooth the line before. The problems remain...

B. in QGIS:

2. clip track
3. extract vertices
5. points to path
6. select by location (intersecting elements of road) -> results with gaps

C. GRASS in QGIS v.edit -> problems of snapping not to the right road perists

D. in POSTGIS:

1. split track in segments of 10m (roads are mostly segments of 10m)
2. calculate Hausdorff distance:
``````CREATE TABLE tracks2 AS
SELECT  a.id, a.geom
WHERE ST_HausdorffDistance(a.geom, b.geom)< 3;
``````

-> to many wrong segments, to many missing segments

E. in POSTGIS: I was thinking of a solution with the change of azimuth between points, but I got troubles with the points between the locations of change and corners. (see my previous question: PostGIS: ST_Azimuth between Points in same Table)

And now I found this: Matching segments of different lengths

How can I implement this in POSTGIS? Or is there a completely different approach (Python, ...)?

I also researched the topics map matching / conflation without finding a solution that suits my problem and my possibilities.

• this is a heuristic problem under the topic 'map matching' and requires a complex algorithm (e.g. using hidden markov models and viterbi backtracking) to approximate a best fit on a fully modeled network. consider using sophisticated routing machines like OSRM (easily applicable via Node.js bindings) or Graphopper (on Java). Commented Aug 21, 2019 at 9:51