cityImage.clean_same_vertexes_edges#
- cityImage.clean_same_vertexes_edges(nodes_gdf, edges_gdf, preserve_direction=False)[source]#
Removes duplicate edges with the same start and end nodes (same vertexes) in a network GeoDataFrame.
- For each pair of edges with the same node pair (‘u’, ‘v’), the function:
Keeps only the longest edge if one is at least 10% longer than the other(s).
If their lengths are similar, generates a center line geometry to represent both and assigns it to one edge.
Drops all other duplicate edges.
Updates the node GeoDataFrame to retain only nodes still referenced by any edge.
If preserve_direction is False, treats edges as undirected (edges (u,v) and (v,u) are considered duplicates). If True, edges in opposite directions are not treated as duplicates.
- Parameters:
nodes_gdf (GeoDataFrame) – GeoDataFrame of nodes (junctions), must include unique node IDs.
edges_gdf (GeoDataFrame) – GeoDataFrame of street segments (edges), must include ‘u’, ‘v’, ‘geometry’, and ‘length’ columns.
preserve_direction (bool) – Whether to preserve edge direction (see above).
- Returns:
nodes_gdf (GeoDataFrame) – Filtered nodes, only those referenced by remaining edges.
edges_gdf (GeoDataFrame) – Deduplicated edges with updated geometry where applicable.