iduedu.nearest_objects¶
- iduedu.nearest_objects(urban_graph, *, gdf_origins=None, gdf_objects=None, origins_nodes=None, object_nodes=None, k=1, cutoff=None, weight='time_min', direction='from', graph_node_column='graph_node_id', max_workers=None)[source]¶
Find the
knearest objects of every origin along the network.Each origin runs one search that stops as soon as
kobjects are found, so the cost does not grow with the number of objects.- Parameters:
urban_graph (
UrbanGraph) – Graph to search.gdf_origins (
DataFrame|None) – Origin objects, withgraph_node_columnor matched to their nearest nodes, orgdf_objects (
DataFrame|None) – Objects to look for, with the same conventions, ork (
int) – Number of objects to return per origin.cutoff (
float|None) – Largest travel cost, inclusive;Nonefor no limit.weight (
Literal['length_meter','time_min']) – Edge cost column:time_min(minutes) orlength_meter(metres).direction (
Literal['from','to']) –"from"measures the way from the origin to the object,"to"from the object to the origin. They differ on directed graphs.graph_node_column (
str) – Column of object tables that holds graph node ids.max_workers (
int|None) – Number of threads;Noneuses all cores.
- Return type:
- Returns:
DataFrame with a
(origin, rank)MultiIndex (rankstarts at 1) and columnsobject(label of the object in its table, or its node id) anddist. Origins with fewer thankreachable objects have fewer rows; objects on the same node keep the order of the object table.- Raises:
ValueError – If
kis not a positive integer, or inputs cannot be resolved to graph nodes.