Reputation: 1
I am a beginner to OSMnx and Python in general, and I'm having a lot of issues plotting in OSMnx. In my AP Research project, I want to use OSMnx to route light rail systems, calculate travel times/speeds, and centrality. I am aware that rail is not a network_type on OSMnx, so I decided to plot my own light rail routes to the best of my ability. I am starting with Norfolk, Virginia, which contains the Tide light rail.
Based on code from the examples gallery and the problems and, consequently, advice from other OSMnx users, I used the code below to plot my own route, which uses two nodes to start, at least:
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point, LineString
import matplotlib.pyplot as plt
import networkx as nx
import osmnx as ox
ox.__version__
place = "Norfolk, VA, USA"
G = ox.graph.graph_from_place(place, network_type="drive")
G = ox.routing.add_edge_speeds(G)
G = ox.routing.add_edge_travel_times(G)
w = "travel_time"
orig, dest = list(G)[8413533280], list(G)[6766842462]
route1 = ox.routing.shortest_path(G, orig, dest, weight=w)
fig, ax = ox.plot.plot_graph_route(G, route1, orig_dest_size=100, node_size=0)
From which the output was:
orig, dest = list(G)[8413533280], list(G)[6766842462]
IndexError: list index out of range
Why are these nodes out of range? How do I solve this issue?
Upvotes: 0
Views: 17