Reputation: 31
To get the right connected components, I projected a graph then use 'osmnx.simplification.consolidate_intersections' to consolidate intersections.
import osmnx as ox
import pandas as pd
import networkx as nx
%matplotlib inline
cities = {'Copenhagen':'Copenhagen Municipality, Denmark'}
G1=ox.graph.graph_from_place('Copenhagen Municipality, Denmark', simplify=False, retain_all=True, truncate_by_edge=True, which_result=None, buffer_dist=None,clean_periphery=True, custom_filter='["highway"~"cycleway"]')
G11=ox.simplification.consolidate_intersections(ox.project_graph(G1, to_crs='EPSG:3812'), tolerance=15, rebuild_graph=True, dead_ends=True, reconnect_edges=True)
G2==ox.project_graph(G11, to_crs='EPSG:4326')
ox.io.save_graphml(G2, filepath='data/Copenhagen_bike.graphml', gephi=True, encoding='utf-8')
print('Copenhagen bike_net saved')
Then comes the question: I saved G1 as GraphML file, but when I tried to load Copenhagen_bike.graphml, it would come error " ValueError: invalid literal for int() with base 10: '14-1' ". I wonder how to load the file to get a graph with no error.
Anyone who offers help will be appreciated.
Upvotes: 0
Views: 297