I used the Python library OSMNx to draw an optimal route between several steps of a city trip. The final variable is a list of OSM ids.
Now, I'm trying to save this route as a shp or json files. The problem is that I need for that the latitude/longitude of each node, but I didn't found an OSMNx function to do that.
I tried get_route_edge_attributes (but coordinates are not a valid attribute for this function). There is any way to get coordinates of an OSM node with this single id ?
Thanks in advance.
G.node[38862848]['y'] for latitude and G.node[38862848]['x'] for longitude
you have all the attribute of each node and edge in the Graph. you can get node attributes using:
and to get edge attributes you can use
G[u][v]
:All attributes are also in GeoDataFrame's of the graph. If you have list of nodes, the easiest way to get the geometry of all nodes is:
the output is a GeoDataFrame.