momepy.consolidate_intersections¶
-
momepy.consolidate_intersections(graph, tolerance=
30, rebuild_graph=True, rebuild_edges_method='spider', x_att='x', y_att='y', edge_from_att='from', edge_to_att='to')[source]¶ Consolidate close street intersections into a single node, collapsing short edges.
If rebuild_graph is True, new edges are drawn according to
rebuild_edges_methodwhich is one of:- Extension reconstruction:
Edges are linearly extended from original endpoints until the new nodes. This method preserves most faithfully the network geometry but can result in overlapping geometry.
- Spider-web reconstruction:
Edges are cropped within a buffer of the new endpoints and linearly extended from there. This method improves upon linear reconstruction by mantaining, when possible, network planarity.
- Euclidean reconstruction:
Edges are ignored and new edges are built as straight lines between new origin and new destination. This method ignores geometry, but efficiently preserves adjacency.
If
rebuild_graphis False, graph is returned with consolidated nodes but without reconstructed edges i.e. graph is intentionally disconnected.Graph must be configured so that
All nodes have attributes determining their x and y coordinates;
All edges have attributes determining their origin, destination, and geometry.
- Parameters:¶
- graph : Networkx.Graph, Networkx.DiGraph, Networkx.MultiGraph, or¶
Networkx.MultiDiGraph
- tolerance : float, default 30¶
distance in network units below which nodes will be consolidated
- rebuild_graph : bool¶
- rebuild_edges_method : str¶
‘extend’ or ‘spider’ or ‘euclidean’, ignored if rebuild_graph is False
- x_att : str¶
node attribute with the valid x-coordinate
- y_att : str¶
node attribute with the valid y-coordinate
- edge_from_att : str¶
edge attribute with the valid origin node id
- edge_to_att : str¶
edge attribute with the valid destination node id
- Returns:¶
directionality inferred from input type
- Return type:¶
Networkx.MultiGraph or Networkx.MultiDiGraph