gdf_edges = utils_graph.graph_to_gdfs(G.subgraph(route), nodes=False, fill_edge_geometry=True)
route_nodes = list(zip(route[:-1], route[1:]))
index = [
gdf_edges[(gdf_edges["u"] == u) & (gdf_edges["v"] == v)].index[0] for u, v in route_nodes
]
gdf_route_edges = gdf_edges.loc[index]
After Change
// create gdf of the route edges in order
node_pairs = zip(route[:-1], route[1:])
uvk = ((u, v, min(G[u][v], key=G[u][v].get("length"))) for u, v in node_pairs)
gdf_edges = utils_graph.graph_to_gdfs(G.subgraph(route), nodes=False).loc[uvk]
// get route centroid
x, y = gdf_edges.unary_union.centroid.xy
route_centroid = (y[0], x[0])