iduedu.graph_stats

iduedu.graph_stats(urban_graph, *, area=None, zones=None, edge_types=None, boundary_buffer=1.0, precision=0.01)[source]

Measures of size, density, shape and connectivity of a street network.

Without area and zones the whole graph is measured. With area only the part of the graph inside it is measured, and with zones every zone separately. In both cases the number of streets at a node is taken from the whole graph, so a graph built with a margin around the study area gives dead ends and intersections free of edge effects. Nodes belong to the zone they lie in, streets and segments to the zone of their midpoint.

Measures (NaN where a measure is undefined):

  • node_count, edge_count (edges as stored), street_count (undirected streets);

  • street_length_total (metres, every physical segment once), street_length_mean;

  • streets_per_node_mean, dead_end_count, dead_end_share, intersection_count (nodes with three or more streets), intersection_4way_share (four or more streets, among intersections);

  • circuity_mean (street length over the straight distance between its ends, loops left out), self_loop_share, parallel_street_share;

  • component_count, largest_component_share (of nodes);

  • beta_index (streets per node), gamma_index (streets over the most a planar graph can have, 3 (v - 2)), cyclomatic_number (independent cycles, e - v + p), meshedness (cycles over the most a planar graph can have, 2 v - 5); they count streets with both ends inside;

  • orientation_entropy (Shannon entropy in nats of segment bearings in 36 bins, weighted by length) and orientation_order (1 for a perfect grid, 0 for uniform bearings);

  • oneway_share (of street length) when the graph has a direction column;

  • speed_mean_kmh (total length over total travel time) when edges have length_meter and time_min;

  • elevation_min, elevation_max, elevation_mean (nodes), grade_mean (mean absolute grade weighted by length) and grade_max when the graph carries elevation (add_elevation());

  • platform_count (nodes of type platform), unattached_platform_count (platforms no walking edge leads to, in graphs that have walking edges) and boarding_edge_count for graphs with public-transport platforms;

  • with area or zones: area_km2, node_density, intersection_density (per km²) and street_density (km per km²).

Parameters:
  • urban_graph (UrbanGraph) – Graph in a projected (metric) CRS.

  • area (BaseGeometry | GeoSeries | GeoDataFrame | None) – Study area: a shapely geometry in EPSG:4326, as territory of the graph builders, or a GeoSeries / GeoDataFrame in any CRS. Several geometries are merged into one area.

  • zones (GeoSeries | GeoDataFrame | None) – Zones to measure separately: a GeoSeries or GeoDataFrame in any CRS. The result has one row per zone, indexed like zones.

  • edge_types (Optional[Iterable[str]]) – Measure only edges whose type is one of these, and the nodes they touch.

  • boundary_buffer (float | None) – With area: nodes with one street closer than this to the area boundary are not counted as dead ends (streets cut by clipping the graph to the area). None counts them.

  • precision (float) – Grid for comparing segment end points, see unique_segments().

Return type:

Series | DataFrame

Returns:

Series of measures, or with zones a DataFrame with one row per zone.

Raises:
  • TypeError – If urban_graph is not an UrbanGraph or area / zones have a wrong type.

  • ValueError – If the CRS is geographic, or both area and zones are passed.