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_meterbetween 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, orgdf_origins (
DataFrame|None) – origin objects (withgraph_node_columnor matched to their nearest nodes).destination_nodes (
Optional[Iterable[Any]]) – Destination node ids, orgdf_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.max_workers (
int|None) – Number of threads;Noneuses all cores.
- Return type:
- Returns:
DataFrame of ratios, origins in rows and destinations in columns;
NaNfor unreachable pairs and for pairs at the same place.result.stack().mean()is the mean directness.