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
See also this on GitHub for more details:
The
xandyattributes are your node coordinates. If your graph is unprojected, then they are in lat-lon (degree units).If you've projected your graph, then
xandyare your projected node coordinates (in meters or whatever units your projected coordinate system uses) and the nodes will also have additionallatandlonattributes that contain the original unprojected coordinates.
import osmnx as ox
G = ox.graph_from_place('Piedmont, CA, USA', network_type='drive')
node_id = list(G.nodes())[0]
G.node[node_id]['x'] #lon
G.node[node_id]['y'] #lat