import%20marimo%0A%0A__generated_with%20%3D%20%220.23.13%22%0Aapp%20%3D%20marimo.App()%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Convert%20a%20Network%20from%20momepy%0A%0A%20%20%20%20Convert%20a%20network%20from%20%60momepy%60%20to%20a%20%60cityseer%60%20compatible%20%60networkx%60%20graph.%0A%0A%20%20%20%20The%20process%20for%20converting%20%60momepy%60%20networks%20is%20the%20same%20as%20for%20other%20street%20network%20datasets%20opened%20via%20%60geopandas%60.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20geopandas%20as%20gpd%0A%20%20%20%20import%20momepy%0A%20%20%20%20from%20cityseer.tools%20import%20io%2C%20plot%0A%0A%20%20%20%20return%20gpd%2C%20io%2C%20momepy%2C%20plot%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Prepare%20a%20%60momepy%60%20street%20network.%20This%20example%20uses%20the%20%60streets%60%20layer%20of%20the%20%60momepy%60%20%60bubenec%60%20example%20dataset%2C%20a%20%60GeoDataFrame%60%20of%20street%20segments.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(gpd%2C%20momepy)%3A%0A%20%20%20%20streets_gpd%20%3D%20gpd.read_file(%0A%20%20%20%20%20%20%20%20momepy.datasets.get_path(%22bubenec%22)%2C%0A%20%20%20%20%20%20%20%20layer%3D%22streets%22%2C%0A%20%20%20%20)%0A%20%20%20%20streets_gpd.head()%0A%20%20%20%20return%20(streets_gpd%2C)%0A%0A%0A%40app.cell%0Adef%20_(streets_gpd)%3A%0A%20%20%20%20streets_gpd.plot()%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20Use%20the%20%5B%60nx_from_generic_geopandas%60%5D(https%3A%2F%2Fcityseer.benchmarkurbanism.com%2Ftools%2Fio%23nx-from-generic-geopandas)%20function%20to%20convert%20the%20%60geopandas%60%20LineStrings%20dataset%20to%20a%20%60networkx%60%20graph.%20This%20function%20will%20automatically%20create%20nodes%20and%20edges%20from%20the%20LineStrings%20in%20the%20dataset.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(io%2C%20plot%2C%20streets_gpd)%3A%0A%20%20%20%20G%20%3D%20io.nx_from_generic_geopandas(streets_gpd)%0A%20%20%20%20print(G)%0A%20%20%20%20plot.plot_nx(G%2C%20plot_geoms%3DTrue)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Conclusion%0A%0A%20%20%20%20This%20notebook%20demonstrated%20how%20to%20convert%20a%20%60momepy%60%20street%20network%20(stored%20as%20a%20%60geopandas%60%20GeoDataFrame%20of%20LineStrings)%20into%20a%20%60cityseer%60-compatible%20%60networkx%60%20graph%20using%20%60nx_from_generic_geopandas%60.%20The%20same%20approach%20applies%20to%20any%20LineString-based%20street%20dataset%20loaded%20through%20%60geopandas%60.%0A%0A%20%20%20%20To%20continue%20into%20analysis%2C%20hand%20the%20prepared%20graph%20to%20the%20high-level%20API%20with%20%5B%60CityNetwork.from_nx%60%5D(https%3A%2F%2Fcityseer.benchmarkurbanism.com%2Fapi%2Fnetwork%23from_nx)%2C%20which%20builds%20the%20dual%20network%20and%20exposes%20the%20centrality%20and%20land-use%20methods.%0A%0A%20%20%20%20**Next%20steps%3A**%20Once%20your%20network%20is%20ready%2C%20proceed%20to%20%5BNetwork%20Centrality%5D(https%3A%2F%2Fcityseer.benchmarkurbanism.com%2Fexamples%2Fcentrality)%20to%20compute%20metrics.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
21395e4db8046bef8c2d877045673ed2