iduedu.project_objects2urban_graph¶
- iduedu.project_objects2urban_graph(graph_gdf, objects_gdf, speed_m_per_min, *, max_dist=None, add_link_edge=True)[source]¶
Prepare graph changes that connect objects to their nearest edges.
The function does not mutate the source graph. It computes nodes and edges to add, source edges to remove, and an
object2nodemapping. In backend services this is the preferred low-level workflow:changescan be persisted to graph tables andobject2node_mapcan be saved on the object table asgraph_node_id. For in-memory workflows, apply the result withapply_urban_graph_changes().Objects are projected by their
representative_point(), so the function works for buildings, services and other polygon or point layers with a stable unique index.- Parameters:
graph_gdf (
UrbanGraph) – Source urban graph.objects_gdf (
GeoDataFrame) – Objects to connect to the graph. The index should be a stable object identifier, such asobject_idorbuilding_id.speed_m_per_min (
float) – Movement speed on created connector edges, in meters per minute. For 5 km/h use5 * 1000 / 60.max_dist (
float|None) – Optional maximum distance from an object to the nearest edge. IfNone, nearest edges are searched without a distance limit.add_link_edge (
bool) – IfTrue, create a dedicated object node and connector edge. IfFalse, map the object to the projection node on the graph.
- Return type:
- Returns:
Pair
(changes, object2node_map).changes.nodes_gdfcontains new nodes,changes.edges_gdfcontains new edges, andchanges.edges_to_deletecontains replaced edge keys.object2node_mapis aSeriesindexed by the original object index with graph node ids as values.- Raises:
TypeError – If
objects_gdfis not a GeoDataFrame.ValueError – If objects are empty or speed/distance parameters are invalid.