iduedu.consolidate_intersections¶
- iduedu.consolidate_intersections(graph, tolerance=10.0, *, max_span=None, return_mapping=False)[source]¶
Merge groups of nearby nodes, such as the several nodes of one junction of dual carriageways, into one.
Two nodes closer than
tolerancebelong to one cluster, and clusters chain (single linkage). A cluster is then split into the parts that edges inside the cluster connect, so nodes that are merely close (a bridge above a road) stay apart. Each part with several nodes becomes one node at the mean position of its members, keeping the id and attributes of its first member innodes_gdforder; single nodes are unchanged. Edges inside a part are removed. The other edges keep their geometry with the end points moved to the new nodes;length_meteris the new geometry length andtime_minis scaled with it.Chaining can join long runs of closely spaced nodes (dense footpath networks); a part whose bounding box is wider than
max_spanis therefore left unmerged.Meant for network statistics and centralities, where one junction drawn as several nodes inflates the counts. It changes routing: turns and one-way links inside a junction disappear.
- Parameters:
graph (
UrbanGraph) – Graph with point nodes and line edges in a projected (metric) CRS.tolerance (
float) – Distance in CRS units under which two nodes are joined.max_span (
float|None) – Largest bounding-box diagonal of a part that is still merged, in CRS units.Nonemeans4 * tolerance.return_mapping (
bool) – Also return the mapping from old to new node ids.
- Return type:
- Returns:
New
UrbanGraphof the same kind (directed or not, multigraph or not; a simple graph keeps the lighter of the parallel edges that merging creates), and withreturn_mappingtheSeriesfrom every old node id to its new one.- Raises:
TypeError – If
graphis not anUrbanGraph.ValueError – If
toleranceis negative, the CRS is geographic or an edge is not a LineString.