iduedu.route_directness

iduedu.route_directness(urban_graph, *, origins_nodes=None, destination_nodes=None, gdf_origins=None, gdf_destinations=None, graph_node_column='graph_node_id', sample=200, seed=0, max_workers=None)[source]

Ratio of the shortest network distance to the straight distance between origins and destinations.

1 means a straight route; a street grid gives about 1.27 on average. Distances are measured by length_meter between graph nodes, and the straight distance between the same nodes, so objects are represented by their nearest nodes.

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

  • origins_nodes (Optional[Iterable[Any]]) – Origin node ids, or

  • gdf_origins (DataFrame | None) – origin objects (with graph_node_column or matched to their nearest nodes).

  • destination_nodes (Optional[Iterable[Any]]) – Destination node ids, or

  • gdf_destinations (DataFrame | None) – destination objects. Without destinations the origins are used.

  • graph_node_column (str) – Column of object tables that holds graph node ids.

  • sample (int) – Without origins, this many random nodes are taken as origins and destinations.

  • seed (int | None) – Seed of the random sample.

  • max_workers (int | None) – Number of threads; None uses all cores.

Return type:

DataFrame

Returns:

DataFrame of ratios, origins in rows and destinations in columns; NaN for unreachable pairs and for pairs at the same place. result.stack().mean() is the mean directness.