I am using this script to import OSM data into a GIS based model.
This has to run independent from any software package such as QGIS, PostGIS, or ArcGIS.
I then create a shortest path between two nodes as follow:
shortest_path = nx.shortest_path(G, source=u'879835512', target=u'879912131') result_graph = G.subgraph(shortest_path)
I would like to visualize (kml?) the results of the shortest path and store them (shp?).
I have a feeling that I need to use the
write_shp but I think that only works if you have already used
read_shp which I haven't since I'm importing directly from OSM.
Based on @gene 's comment, I added the following code:
for e in result_graph.edges(): p0x = result_graph.node[e]['lat'] p0y = result_graph.node[e]['lon'] p1x = result_graph.node[e]['lat'] p1y = result_graph.node[e]['lon'] edges.append(LineString([(p0x, p0y), (p1x, p1y)])) nodes =  for n in result_graph.nodes(): px = result_graph.node[e]['lat'] py = result_graph.node[e]['lon'] nodes.append((px,py)) G2 = nx.DiGraph() G2.add_nodes_from(nodes)
I don't think I'm on the right track yet. as it seems I need to maintain the coordinates somehow with my nodes/links