iduedu.nearest_edges¶
- iduedu.nearest_edges(urban_graph, gdf, *, max_dist=None)[source]¶
Return the nearest graph edge for each input geometry, with the distance and the position along it.
Objects are matched by their
representative_point()in the graph CRS, as innearest_nodes(). This does not change the graph; useproject_objects2urban_graph()to insert objects into it.- Parameters:
urban_graph (
UrbanGraph) – Graph whoseedges_gdfcontains line geometries.gdf (
GeoDataFrame) – GeoDataFrame with geometries to match to graph edges.max_dist (
float|None) – Optional search radius in graph CRS units; objects farther from every edge get missing values.Nonesearches without a limit.
- Return type:
- Returns:
DataFrame indexed like
gdfwith columnsedge(label of the edge inedges_gdf),u,v(andkfor multigraphs),dist(distance from the object to the edge) andalong(distance from the start of the edge geometry to the closest point on it). When several edges are equally near, one of them is returned.- Raises:
TypeError – If
gdfis not a GeoDataFrame.ValueError – If the graph has no edges or geometries cannot be matched safely.