-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map matched route does not perfectly align with road network #5960
Comments
OSRM only stores 6 decimal places of fixed precision for coordinates (about 10cm precision at the equator). OSM (and the PBF you downloaded) uses a 7-decimal places fixed precision format (about 1cm at the equator). So there's already up to 9cm of error introduced by that truncation. OSRM saves space by not bothering with that extra decimal place - it was deemed unnecessary for navigation purposes. OSM itself is hardly accurate to 1cm, well, anywhere. What you should be doing for this comparison is using the |
Thanks, that sounds like a much better solution. Where exactly do I find the node ID's in the OSM road network? I expected them to find in the Points layer of the PBF file I downloaded from geofabrik. |
What tool are you using to inspect the PBF? Every coordinate in the file has an associated node ID - in XML format, they look like this:
It'll be up to your tool to decide whether to display the node ID or not. |
I'm using QGIS. What tool do you recommend? |
Not QGIS - it throws away the node IDs. What exactly is your desired output of this process? You will be able to get all the pairs and geometry from the OSRM API response alone. This would allow you to tabulate and rank the most common segments, and display them visually, no joining to a PBF required. |
My initial idea was to (1) extract all node id's from the OSRM API (2) add them to a pandas dataframe and count each occurence (3) joining the number of occurences/hits of the node id's with the corresponding line segments in QGIS. But apparently there is another way to tabulate and rank the most common segments and visualize them. What would you recommend? |
How are you defining the rows in your road network table? A vehicle can turn off any given road name at any intersection - I assume you'd want to know if some sections of a named road have more visits than others? |
Here's a script that will match an array of traces, collate all the number of times each piece of geometry is visited, and output GeoJSON features with a
You can probably do a pass over this geojson to join directly-connected lines together into contiguous features to get nicer visualization. |
@danpat I'm a little bit a noob with OSRM and plotting a route in an OSRM map. I'm testing with the |
@Rougree you may want to start with osrm-frontend https://github.com/Project-OSRM/osrm-frontend/ (see docs over there on how to point it to your own OSRM instance). |
@danpat thanks for sharing your script. This is probably the method I should use, since I would like to use a custom road network for the analysis in the end. Although I have been able to convert a custom road network from .shp to .osm using ogr2osm (and successfully map match the GPS points to this network), the original node id's from the shapefile appear to have lost after conversion. I was hoping ogr2osm would be able to transfer the node id's from the .shp to the .osm file, as the original shapefile contains a column "source" and a column "target" to indicate the node id's. Instead, new node id's have been chronologically numbered in the .osm file (see below), which makes it useless to count the node id pairs. Btw, I tried to rerun your script with a different trace:
This trace visits some streets a couple of times. However, this isn't translate to the count, which is 1 for all geometries. Do you get the same result? |
I cannot reproduce your results without your map, I only have access to OpenStreetmap. I would suggest you check the results of your
If (1) and (2) haven't been done, then the network you're trying to match is basically junk. I'm not sure how much magic Try opening up your |
There is no way that a node has no id. Ways reference nodes only by id and have no coordinates of their own. But the node looks like a "new" node in josm. Maybe it's just a negative id which is usually used for new elements in editors. |
That's correct, I meant that the original node id's are lost. In the screenshot of the .osm file you can see that |
The script I posted, if you read it carefully, is only working with the coordinates, not the node IDs. The critical line for detecting repeated visits to the same pair is this one:
My Python is a bit rusty - I'm assuming that two separately constructed tuples containing the same numeric values will cause the above to evaluate to |
I understand, but given the trace I posted above (see also map below), you would expect a couple more counts for some coordinate pairs (see output at bottom). My python is also not very developed, so I might miss the reason why this is happening. It seems it has to do with the fact that only unique coordinates pairs are counted
|
I've map matched a series of GPS points to the OSM road network (downloaded from geofabrik) using the following options:
overview=full
geometries=polyline6
tidy=true
According to the documentation, these options should yield the highest precision in terms of OSRM route geometry. However, when zooming in you can see that the map matched route (red) does not exactly align with OSM's road network (green). I measured gaps ranging from 1 millimeter to 50 millimeters.
My goal is to provide insight in where but more importantly how frequently the vehicle has been per road segment in the road network. If the map matched route would have perfectly aligned with the road network, I could have counted the number of overlapping (route) lines per street segment. Is it possible to increase the precision of the map matched route so that it perfectly aligns with the OSRM road network? For example by using other options than mentioned above? Or does someone have a better workflow for what I'm trying to achieve?
The text was updated successfully, but these errors were encountered: