Knowing when Graphhopper is snapping a point on the road

Hey all!

When the starting or destination points are outside the graph, the routing engine automatically finds the nearest graph node and snaps the result to that point.

Screenshot 2024-03-06 at 16.32.48

Is this distance accounted in the overall distance? Is it possible in any way to get information about that using the API (for example the original starting/destination point along with the snapped point and the flight distance between the two)?

The route distance only goes between the snapped coordinates. But you’ll get snapped_waypoints in the response JSON (same format as points) and can calculate foot path distances or beeline distances based on this and your request coordinates.

1 Like

What kaussell said.
I have dealt with this previously and the easiest method is just to include an “as the crow flies” distance calc towards and back from the intended location.
Its important to note that if you are wanting to calculate only vehicle distances, you may not want to include this as it has the potential to be walked due to no vehicle access.
Also, this would exclude a time calculation.