Adapt output Graphhopper: get the list of road segment from GPX trace

Hello Graphhopper users

I am a new bee with GIS and I would like to use this software for map-matching (snapping)

I’ve GPS trace (Geolife trace) and I convert it to GPX format

This trace doesn’t provide osm file so and since it is in Beijing I download the OSM file of that city and I will use it as map file, I am right ?

by using Graphhopper, I am not interested on visualizing the GPX trajectories but my need is to get the sequence of road (road id) traversed by each vehicle(person) so offline map-matching is possiblie I guess?

How to do this with GraphHopper software, is it possible to get this output with Graphhopper?

Thank you in advance

Best regards

You can get “road”-ids via traversal_keys=true where you need to keep in mind two things:

  • the traversal key contains the direction and divided by 2 results in a GraphHopper edge ID
  • these edge IDs (and also the traversal keys) are volatile, i.e. a different OSM file, even from the same area, will produce different IDs.

One way to workaround the second point is to fetch the volatile node IDs and grab OSM IDs from them (I’m explicitly mentioning node IDs here as all OSM IDs are volatile too but OSM node IDs are a bit ‘more static’). At the moment getting the list of OSM node IDs is not possible without coding but have a look into https://github.com/karussell/graphhopper-osm-id-mapping on how to store and fetch OSM IDs too.

Thank you for the reply

1- Do you to say that I write ./map-matching.sh action=match traversal_keys=true gpx=./some-dir/*.gpx

2- I didn’t understand this sentence “Traversal key contains the direction and divided by 2 results in a GraphHopper edge ID”, I want to have two road segment ID in the same road if their directions are different is it OK?

3- I have one OSM file and many GPX file, I don’t think it is a problem?(having different road ID for same area)

4- I have many GPX files is thaere a way to match them once of time?

Thank you once again for your time

Best regards

I assumed you are using the matching service where you add the parameter to the URL via &traversal_keys=true, you start it via the command here: https://github.com/graphhopper/map-matching#ui-and-matching-service

I want to have two road segment ID in the same road if their directions are different is it OK?

You can then just use the traversal keys directly. But to understand the issue: GraphHopper just stores edges independent on the direction but here it returns edgeId*2 and does plus 0 or plus 1 dependent on the direction. Understanding this is necessary only if you want to dig deeper into the system

3- I have one OSM file and many GPX file, I don’t think it is a problem?(having different road ID for same area)

If you update this OSM file this will result in different IDs than in the previous OSM

4- I have many GPX files is thaere a way to match them once of time?

Use the matching web service or the command line you specified above via an asterix grabbing multiple files

Thank you Mr karussell , I really appeciate

I will try this and tell you

Thank you once again

Best regards

Hi @karussell Could you elaborate on the way to pass multiple gpx files in the web service api ?
Is there any documentation around it ?
Thanks

Powered by Discourse