Convert a network from osmnx

Convert a network from osmnx to a cityseer compatible networkx graph.

import osmnx as ox
from cityseer.tools import plot, io

Use one of the available osmnx methods to create a networkx graph.

lng, lat = -0.14115725966109327, 51.509220662095714
buff = 500

multi_di_graph = ox.graph_from_point((lat, lng), dist=buff, simplify=True)
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.

G = io.nx_from_osm_nx(multi_di_graph)
print(G)
plot.plot_nx(G, plot_geoms=True)
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