How do I get the path as a geometry from networkx?
Below is my worked example which returns the nx.shortest_path_length
import osmnx as ox
import networkx as nx
from shapely.geometry import Point
def get_network(centre_point, dist):
G = ox.graph_from_point(centre_point, dist=dist, network_type='walk', simplify=False)
G = ox.add_edge_speeds(G)
G = ox.add_edge_travel_times(G)
nodes, edges = ox.graph_to_gdfs(G, nodes=True, edges=True)
return G, nodes, edges
point = (50.864595387190924, -2.153190840083006)
G, nodes, edges = get_network(centre_point=point, dist=1000)
a = nodes.iloc[4].name
b = nodes.iloc[20].name
nx.shortest_path_length(G, a, b, weight='length', method='dijkstra')
This gives the shortest path length as 223.964
, how do I get the actual path geometry of this shortest path? The paths are in edges
but how do I extract the correct ones for this path?