Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add networkx conversion from momepy street network? #80

Open
songololo opened this issue Aug 19, 2023 · 3 comments
Open

Add networkx conversion from momepy street network? #80

songololo opened this issue Aug 19, 2023 · 3 comments

Comments

@songololo
Copy link
Collaborator

@martinfleis

I'm wondering about adding a conversion function for a momepy street network GeoDataFrame to cityseer compatible networkx MultiGraph .

Here is an initial sketch of what this might look like: momepy_to_cityseer

This would mainly be intended for people who want to:

  • run street network centralities on larger street networks
  • calculate network centralities using cityseer's methods which adapt the shortest-path algorithms to work for some situations which aren't necessarily covered by e.g. networkX (e.g. shortest path sidestepping issue)
  • calculate landuse accessibilities over the street network (weighted and unweighted)
  • calculate mixed-uses over the street network (weighted and unweighted)
  • aggregate statistics (e.g. building form metrics from momepy) using the street network as a backbone

I'm curious what your thoughts are on things to take into account so that this is useful, e.g.

  • would there be use cases where people might want to do a round-trip - e.g. momepy GeoDataFrame to cityseer then back to momepy? If so, the edge ids would need to be chained through. The drawback to a round-trip is that network cleaning or decomposition can't be done without losing the association.
  • the current conversion function doesn't take primal or dual into account, it just builds a network from the edges. This is probably a non-issue unless doing a round-trip as people can simply manipulate the graphs either end depending on what they want to do.
  • would there be more interest in going straight from a GeoDataFrame or would there be cases where it is better to go from a momepy formatted networkx Graph?

There are probably other things but that's all that comes to mind for now...

@martinfleis
Copy link
Contributor

This would certainly be useful. I would probably also be keen to replace networkx with cityseer as an engine for some of our functions internally.

would there be use cases where people might want to do a round-trip

I suppose so.

would there be more interest in going straight from a GeoDataFrame or would there be cases where it is better to go from a momepy formatted networkx Graph

That doesn't matter much imho. GeoDataFrame is the primary structure so having I/O with that is probably better than going via Graph.

cc @jGaboardi

@songololo
Copy link
Collaborator Author

Added a io.nx_from_generic_geopandas method which can ingest LineString GeoPandas data frames and covert them to networkX graphs with geom attributes on the edges. This works for ingesting most LineString DataFrames but let me know if it would help to have a io.nx_from_momepy_geopandas method with custom logic for momepy.

Example added at momepy_to_cityseer.ipynb.

@martinfleis
Copy link
Contributor

How different is cityseer-compatible graph from that created with momepy.gdf_to_nx? If we want to optionally depend on cityseer to do centralities, which I think we want, we would need to go from the graph to cityseer structure rather than from geodataframe. Otherwise we'd need to convert graph to geodataframe to create graph again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants