I'm generating a list on nodes ids according to get_nearest_node with OSMnx and generate a route between origin and destination that pass all the nodes in my list.
Python code:
ids = []
for r in range(len(df)):
location = df.iloc[r]['location'] #(lat,lon)
some_node_id = ox.get_nearest_node(GG,location)
ids.append(some_node_id)
for id in range(len(ids)-1):
route = nx.shortest_path(GG,ids[id],ids[id+1])
m = ox.plot_route_folium(GG, route, route_color='green') #ERROR at this line
m.save('route.html')
I tried to print ids list and it looks fine, so what could be the reason for this error?
AttributeError Traceback (most recent call last)
<ipython-input-91-fc82d1877717> in <module>
23 for id in range(len(ids)-1):
24 route = nx.shortest_path(GG,ids[id],ids[id+1])
---> 25 m = ox.plot_route_folium(GG, route, route_color='green')
26 st = 'date {da}.html'.format(da=d)
27
~\Anaconda3\lib\site-packages\osmnx\plot.py in plot_route_folium(G, route, route_map, popup_attribute, tiles, zoom, fit_bounds, route_color, route_width, route_opacity)
919
920 # get route centroid
--> 921 x, y = gdf_route_edges.unary_union.centroid.xy
922 route_centroid = (y[0], x[0])
923
~\Anaconda3\lib\site-packages\shapely\geometry\point.py in xy(self)
145 [0.0]
146 """
--> 147 return self.coords.xy
148
149
AttributeError: 'list' object has no attribute 'xy'
TIA