Snapping GPX on partial network


Mapmatching is working great when dealing with a track with all points near the network.
However there are situations where some of the track points are and should stay out of the network. In such case, I would expect the mapmatching output to contain: points snapped on the network, points not aligned with the network.

Is this a target usecase of the map-matching algorithm?
If yes, is it already possible to achieve this with some configuration / code? Or is there some plan / roadmap for such functionnality?

Thanks in advance for your feedback.

Some more details and error messages:

Imagine that someone does a Triatlon and records a GPX of it. He then wants to mapmatch it, but only for the parts that are near to the road network. Not for the part when he was swimming. Similar situations could be cases when a user takes a canoe for a part of his outing, or is crossing a glacier, or more simply just going through a field instead of staying on the road.

At the moment, if we simulate this with a sample GPX walkandboat.gpx (31.1 KB) [1], mapmatching is not supporting such cases.

Either we get an unrealistic deviation [2], or we get an error [3].

Instead of returning an error, to handle such cases, we would need the response to contain the parts that could be snapped, and the parts that could not be snapped.


Result with gpx_accuracy=50

Result with gpx_accuracy=40

message: “Sequence is broken for submitted track at time step 34. observation:Observation{point=47.12943761221159,8.602473365849002,0.0}, 1 candidates: [distance: 470.5736894158046 to 47.127124975482936,8.59726407223785,724.43701171875]. If a match is expected consider increasing max_visited_nodes.”

Hi, @karussell, @easbar, and Michaz (whose discuss nickname I don’t know), you have worked the most on the mapmatching functionnality. Would you have some inputs on this topic?

There are some workarounds that could be implemented in client code like adapatively splitting the GPX in shorter pieces and using straight lines on the portions of route with error / unreasonable length. But I would not go that way if there is interest for a global solution in Graphhopper itself.

Let me know what makes sense / or not for the project and I will see what I can do to help getting there.

I don’t understand these two sentences. But it sounds like you want an option to ignore GPS points that are too far away from the road network?

Hi @easbar, sorry I was not notified of your reply.

But it sounds like you want an option to ignore GPS points that are too far away from the road network?

Yes exactly: some GPS points could be far from the network and that would be correct (swimming, crossing a field, walking on a glacier, …). In that case the result of the mapmatching would contain both points on the network (mapmatched) and points out of the network (which could not be mapmatched).

Do you think it is possible to achieve this in graphhopper?

Yes, pretty sure this is possible, but it would require adjusting the (Java) map matching code for this. I don’t think there is any option that does this out of the box.

Hi all, I’m encountering the same problem as @gberaudo has described here. Did you already implement something in the code that can do this or do you know of an easy way to implement this myself? Thanks in advance!

Hi all,

I have the same requirement. In my use case, bicyclists/motorcyclists would set out to explore some trails which aren’t part of the OSM network currently. For those sections which are part of the OSM network, I want the matched map, and for the rest (defined by a limiting differential distance ‘X’ metres between the GPS trace and a known route on OSM), I want the original GPS trace to be retained.

Please do let me know in case there is a way to do this out of the box - by defining the distance ‘X’.

@gberaudo , @LennardD - would be much obliged if you can help me out on how you solved for this requirement