I have a set of origin-destination coordinates that I want to calculate the shortest paths between them.
My origin-destination coordinates are sometimes located in the middle of a long straight-line road. However, the shortest path calculated by OSMnx/networkx will not consider that mid-edge to nearest-node path.
Is there any ready function in OSMnx or networkx that I can use to find shortest path that originates/ends in the middle of the road?
If there is no such function, I am thinking of using the following steps.
OSMnx produces a networkx graph object for routing/analysis. As you note, networkx shortest path calculation takes an origin and a destination node, so trying to calculate a shortest graph path from an edge midpoint won't work.
A couple things you could try:
simplify=False when you create the graph to retain as many nodes in the middle of streets as possible.See also: https://stackoverflow.com/a/55601732/7321942
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With