import osmnx as ox
from cityseer.tools import plot, io
Convert a network from osmnx
Convert a network from osmnx
to a cityseer
compatible networkx
graph.
Use one of the available osmnx
methods to create a networkx
graph.
= -0.14115725966109327, 51.509220662095714
lng, lat = 500
buff
= ox.graph_from_point((lat, lng), dist=buff, simplify=True)
multi_di_graph print(multi_di_graph)
MultiDiGraph with 1529 nodes and 4145 edges
Use the nx_from_osm_nx
function from the cityseer
io
module to convert the osmnx
dataset to a cityseer
compatible networkx
graph.
= io.nx_from_osm_nx(multi_di_graph)
G print(G)
=True) plot.plot_nx(G, plot_geoms
INFO:cityseer.tools.io:Converting OSMnx MultiDiGraph to cityseer MultiGraph.
WARNING:cityseer.tools.util:The to_crs_code parameter 4326 is not a projected CRS
INFO:cityseer.tools.plot:Preparing graph nodes
INFO:cityseer.tools.plot:Preparing graph edges
MultiGraph with 1529 nodes and 2332 edges