1

Problem as shown in the image: enter image description here 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

  1. buffer road
  2. clip track
  3. extract vertices
  4. snap to road
  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:

  1. buffer road
  2. clip track
  3. extract vertices
  4. snap to road
  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
FROM roads a, track1 b 
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.

1
  • 2
    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).
    – geozelot
    Aug 21 '19 at 9:51
1

As aicun said, it's a very complicated problem that require a specific implementation (OSRM, Graphopper, ...). You can also find API (like mapbox) that do that without needing to run the application. I think there is also a QGIS extension to that (I found Offline-MapMatching, maybe there is others)

If you want to stay in Postgis and azimuth maybe look into pg-routing, like they tried here: projecting-gps-point-to-point-in-closest-pgrouting-road-map-matching

It's not like a true map-matching, but maybe that can be enough for you. But to be honest, specialized API are way more, in the middle/long term, time efficient. Because if you want to handle it yourself, even with a simplest logic, there is like a LOT of special cases to handle, especially if you use road data for exemple from OSM where the data you need (oneway, no entry) can be in a lot of different fields / relations).

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .