Skip to content

Commit

Permalink
Merge pull request #38 from amanmajid/master
Browse files Browse the repository at this point in the history
Generalise merge_edges function
  • Loading branch information
tomalrussell authored Jul 27, 2021
2 parents 063f3b5 + 8ba5231 commit 167d72e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ docs/source/api/*
*.dbf
*.shx
*.cpg
__init__.py
7 changes: 2 additions & 5 deletions src/snkit/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def link_nodes_to_nearest_edge(network, condition=None):
)
return split_edges_at_nodes(unsplit)

def merge_edges(network):
def merge_edges(network,**kwargs):
""" Merge edges that share a node with a connectivity degree of 2
"""
if 'degree' not in network.nodes.columns:
Expand Down Expand Up @@ -375,10 +375,7 @@ def merge_edges(network):
unique_edge_ids = set()
for edge_path in edge_paths:
unique_edge_ids.update(list(edge_path.id))
if edge_path.bridge.isnull().any():
edge_path = edge_path.copy()
edge_path['bridge'] = 'yes'
concat_edge_paths.append(edge_path.dissolve(by=['infra_type'], aggfunc='first'))
concat_edge_paths.append(edge_path.dissolve(by=kwargs.get("by", None)))

edges_new = network.edges.copy()
edges_new = edges_new.loc[~(edges_new.id.isin(list(unique_edge_ids)))]
Expand Down

0 comments on commit 167d72e

Please sign in to comment.