I am trying to add an attribute to my nodes in the osmnx network I have in order to use the ox.plot.get_node_colors_by_attr()
later on.
However I am unable to properly add the attribute.
Here is the code:
city = 'Portugal, Lisbon'
G = ox.graph_from_place(city, network_type='drive', simplify=True)
G_nx = nx.relabel.convert_node_labels_to_integers(G)
nodes, edges = ox.graph_to_gdfs(G_nx, nodes=True, edges=True)
nodes['attr'] = 0
i = 0
for node in G_nx.nodes:
nodes['attr'][node] = r_total[0][i] ##r_total[0][i] contains the values I am adding
i +=1
This gives me:
Which is incorrect since the attr column is just all 1.
Here are a few values of my list:
r_total[0] = [1.1437781610893372,1.1581102825247183,1.352684838232266,1.0511223206671774,1.1369540060020151,
1.1639685722826303,1.3451475522422993,-1,1.0416972740013004,1.0240843300890685,1.411806610408149...]