You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My proposal is not addressed by the documentation or examples
Existing issues
Nothing similar appears in an existing issue
What problem does your feature proposal solve?
OSMnx currently has two simplifications options:
simplify_graph
consolidate_intersections
I think there is a use case for a third one: merge_parallel_edges. It does exactly what it says: If you have multiple parallel edges – both starting and ending at the same node – it merges it to a single edge. This can be very useful for more mesoscopic models that don't need the extensive detail of for example multiple parallel highways.
What is your proposed solution?
Introduce a merge_parallel_edges function to simplify MultiDiGraphs into DiGraphs by merging parallel edges.
Some considerations:
NetworkX doesn’t have a built-in function for converting to DiGraph (that gives any control over which edges to keep or how to merge)
Some attributes should be nicely aggerated – for example, lane count can be summed
You might want to have an argument to exclude some edges from merging – for example if the max_speed is different (then you won’t end up with a clean DiGraph though)
In most cases, you want to merge parallel edges after consolidating intersections
What alternatives have you considered?
Manual pre-OSMnx manipulation of graph data to merge edges is inefficient and prone to errors. It also doesn't handle merging attributes cleanly.
Additional context
A basic API outline:
defmerge_parallel_edges(G, attribute_merge_strategy={'lanes': 'sum'}, exclude_criteria=None):
""" Merges parallel edges in G. Allows attribute aggregation and exclusion based on criteria. """# Placeholder for implementation
Introduce a merge_parallel_edges function to simplify MultiDiGraphs into DiGraphs by merging parallel edges.
Note that the convert module's to_digraph function currently does similar: converting a MultiDiGraph to a DiGraph by choosing between parallel edges by minimizing some weight attribute. This does not aggregate attributes across the parallel edges.
Contributing guidelines
Documentation
Existing issues
What problem does your feature proposal solve?
OSMnx currently has two simplifications options:
simplify_graph
consolidate_intersections
I think there is a use case for a third one:
merge_parallel_edges
. It does exactly what it says: If you have multiple parallel edges – both starting and ending at the same node – it merges it to a single edge. This can be very useful for more mesoscopic models that don't need the extensive detail of for example multiple parallel highways.What is your proposed solution?
Introduce a
merge_parallel_edges
function to simplify MultiDiGraphs into DiGraphs by merging parallel edges.Some considerations:
What alternatives have you considered?
Manual pre-OSMnx manipulation of graph data to merge edges is inefficient and prone to errors. It also doesn't handle merging attributes cleanly.
Additional context
A basic API outline:
CC @anastassiavybornova, @martinfleis, @jdmcbr and @jGaboardi
The text was updated successfully, but these errors were encountered: