• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How can I solve the problem occur in osmnx plot_graph_route() KeyError: ‘length’

Resolved: How can I solve the problem occur in osmnx plot_graph_route() KeyError: ‘length’

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

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.
As a result of my testing, it is assumed that an error occurs between the two nodes in List A below. Both nodes are connected, and an error occurs even though I arbitrarily added an edge between the two nodes. The path between the nodes is the result obtained by using the netwokX’s shortest_path_length() function.
this is my code
thank you

Answer:

As your error suggests, your new edges lack a length 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_lengths

If you have better answer, please add a comment about this, thank you!

networkx osmnx python
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How can I write CSS selector(s) that apply to table rows for all td elements on that row after a td with a certain class?

01/04/2023

Resolved: How do I use SetWindowText with Unicode in Win32 using PowerShell?

01/04/2023

Resolved: Shopware 400 Status Error “This value is too long. It should have 255 character or less.” When I Try Updating Database Table

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.