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_method
which 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_graph
is 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:
- graphNetworkx.Graph, Networkx.DiGraph, Networkx.MultiGraph, or
Networkx.MultiDiGraph
- tolerancefloat, default 30
distance in network units below which nodes will be consolidated
- rebuild_graphbool
- rebuild_edges_methodstr
‘extend’ or ‘spider’ or ‘euclidean’, ignored if rebuild_graph is False
- x_attstr
node attribute with the valid x-coordinate
- y_attstr
node attribute with the valid y-coordinate
- edge_from_attstr
edge attribute with the valid origin node id
- edge_to_attstr
edge attribute with the valid destination node id
- Returns:
- Networkx.MultiGraph or Networkx.MultiDiGraph
directionality inferred from input type