2

Using OSRM I have map matched a series of GPS points to a custom road network. My goal is to provide insight in where but more importantly how many times the vehicle has visited each road segment in the road network by counting the number of overlapping map matched trajectories per road segment. However, since OSRM only stores 6 decimal places of fixed precision for coordinates (about 10cm precision at the equator) and my roadnetwork uses a 7-decimal places fixed precision format (about 1cm at the equator), there's up to 9cm of error introduced by that truncation. Therefore, I first need to snap the map matched trajectories (red) to the nearest road segment (green). enter image description here

My desired output is a table snapped_lines in which the map matched trajectories are snapped to the road network (i.e. the red lines lay exactly on top of the green lines). Since the map matched trajectories are not too far away from the road network, I was hoping ST_SNAP should work. Executing this query takes ages however, so I was wondering whether something is wrong.

DROP TABLE IF EXISTS snapped_lines;
CREATE TABLE IF NOT EXISTS snapped_lines AS ( 
  SELECT 
    ST_Snap(
      a.line_geom,
      b.geom,
      1.1) as geom
  FROM
    mapmachted_trajectory AS a
    roadnetwork AS b);
2
  • What if you buffer the road lines to account for the potential deviation of the trajectory and use the resulting polygons to see if the trajectory is in or out?
    – Techie_Gus
    Commented Feb 25, 2021 at 12:54
  • 1
    You have polynomial expansion here. Each point is being snapped to every line, not just the closest. Use JOIN to join (FROM table lists date to the 80's) and constrain by distance.
    – Vince
    Commented Feb 25, 2021 at 12:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.