Question:
I am currently developing an optimal delivery algorithm for parcel delivery. I have a question because I encountered a problem with the plot_graph_route() function of OSMNX while developing the program. When I coded like the code below, I get a result of KeyError: ‘length’.Here is the error code.
this is my code
Answer:
As your error suggests, your new edges lack alength
attribute, which the plot_graph_route
function needs. You can add it manually or use the add_edge_lengths
function. https://osmnx.readthedocs.io/en/stable/osmnx.html#osmnx.distance.add_edge_lengthsIf you have better answer, please add a comment about this, thank you!