diff --git a/growbikenet/functions.py b/growbikenet/functions.py index f018890..9cef472 100644 --- a/growbikenet/functions.py +++ b/growbikenet/functions.py @@ -567,10 +567,11 @@ def remove_edge_overlaps(edges_in): grown_net = MultiLineString() for row in edges_in.itertuples(): grown_net_new = grown_net | row.geometry # Union - if grown_net_new.length > grown_net.length: - edges_out.loc[row.Index, ['geometry']] = grown_net_new - grown_net # Difference - else: # There was nothing added, so we delete the row + grown_net_diff = grown_net_new - grown_net + if grown_net_diff.is_empty: # There was nothing added, so we delete the row edges_out.drop(index=row.Index, inplace=True) + else: + edges_out.loc[row.Index, ['geometry']] = grown_net_diff # Difference grown_net = grown_net_new return edges_out diff --git a/growbikenet/growbikenet.py b/growbikenet/growbikenet.py index ea624c0..b64f088 100644 --- a/growbikenet/growbikenet.py +++ b/growbikenet/growbikenet.py @@ -203,6 +203,7 @@ def growbikenet( ### Compute edge attributes print("Computing edge attributes..") + # The ranking=="random" case has no edge attributes and is handled in rank_df if ranking == "betweenness_centrality": # Add betweenness attributes to edges bc_values = nx.edge_betweenness_centrality( @@ -216,6 +217,7 @@ def growbikenet( cc_values = node_to_edge_attributes(cc_values_nodes, A.edges) nx.set_edge_attributes(A, cc_values, name="closeness_centrality") + ### Export attributes to gdfs: # Create dataframe and add method as edge attribute @@ -237,10 +239,11 @@ def growbikenet( # Remove edge overlaps if not allow_edge_overlaps: - a_edges = remove_edge_overlaps(a_edges) + print("Removing edge overlaps..") + a_edges = remove_edge_overlaps(a_edges) # Can take a while, could be sped up. overlap_string = "" else: - overlap_string = "_overlap" + overlap_string = "_with-overlaps" # Add lengths and cumulative lengths, rounded to integer meters a_edges['length'] = a_edges.geometry.length