Network Preparation

The below examples illustrate how to create cityseer compatible networkx graphs from various data sources, including OpenStreetMap (OSM) data and geopandas GeoDataFrames. These workflows will automatically prepare the network for you, and this should be sufficient for the great majority of cases.

If you specifically wish to prepare the network manually:

The network nodes require x and y attributes storing the coordinates of the node in a projected coordinate system. You can also optionally add the following two attributes:

For edges, cityseer network representations contain a geom attribute which stores a shapely LineString geometry of the edge. cityseer will use the geom attribute to calculate properties of the network such as the lengths of streets and their angular deviations. For the best to results the topology of the graph should reflect the real world topology of the street network and should not be conflated with the geometric representation of the streets. Curvatures and turns within a street segment should be represented within the same LineString geometry rather than adding additional nodes and segments, which would otherwise distort the outcomes of centrality measures.

The first several examples use the osm_graph_from_poly function available from the cityseer package’s io module. This is a versatile function for generating networks from OSM data.

OSM network from a bounding box

Use a bounding box to create a networkx graph from OpenStreetMap data. See this example for some use cases including how to use specific Coordinate Reference Systems.

Notebook

OSM network from a buffered coordinate

Use a buffered point to create a networkx graph from OSM.

Notebook

OSM network from a boundary file

Use a custom boundary file to create a networkx graph from OSM.

Notebook

OSM network from a relation id

Use an OSM relation id to create a networkx graph from OSM.

Notebook

Custom network from a streets dataset

Use geopandas to open a street network file and convert it to a networkx graph.

Notebook

Convert a network from osmnx

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

Notebook

Convert a network from momepy

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

Notebook

Saving a network to a file

Save a networkx graph to a file.

Notebook

Dual graph from a primal graph

Create a dual graph representation from a primal graph.

Notebook

Custom network simplification

For purposes of network analysis, good sources of street network data, such as the Ordnance Survey’s OS Open Roads, typically have two distinguishing characteristics:

  • The network has been simplified to its essential structure: i.e. unnecessarily complex representations of intersections, on-ramps, divided roadways, etc., have been reduced to a simpler representation concurring more readily with the core topological structure of street networks.
  • The topology of the network is kept distinct from the geometry of the streets. Often-times, as can be seen with Open Street Map, additional nodes are added to streets to represent geometric twists and turns along a roadway. These additional nodes cause topological distortions that impact network centrality measures.

When a high-quality source is available, it may be best not to attempt additional clean-up unless there is a particular rationale for doing so. On the other hand, cleaning and simplification is recommended when working with Open Street Map data. cityseer has an automated cleaning routine for OSM data, but it is also possible to manually configure network simplification steps and parameters as shown in the following notebook.

Notebook