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).
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 (
1.1) as geom
mapmachted_trajectory AS a
roadnetwork AS b);