简体   繁体   中英

Exporting a graph as graphml in python

I am new to python and I wanted to export a graph (transportation network) which I constructed using a python package called OSMnx. I am unable to export it as a graphml file for further analysis of the network. I have attached the code I used and the error message I am encountering. Please help.

import osmnx as ox
import networkx as nx
G = ox.graph_from_address('Downtown, Saint Louis, MO', network_type='drive')
nx.write_graphml(G, "g.graphml")

Error message

OSMnx has a built-in function for saving street networks as GraphML files, to serialize dict attributes of the nodes and edges:

import osmnx as ox
G = ox.graph_from_address('Downtown, Saint Louis, MO', network_type='drive')
ox.save_graphml(G, filename='g.graphml')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM