Closed Mohammed-9089 closed 3 years ago
You need to check the details of the gdf_edges
data frame to see which field causes this problem.
Thanks for replying, yes I did it the "fid" column is contain tuples, so when I remove it I can save the file. So how can I address this issue, thanks. @cyang-kth
@cyang-kth The problem because "fid" column is contain tuples, so how can we remove it, while the fmm using this filed. (fmm/example/osmnx_example/map_matching.ipynb) here using this filed.
Read network and graph: network = Network("stockholm/edges.shp","fid", "u", "v")
The fid field should not be tuple
gdf_edges["fid"] = gdf_edges.index
Can you check which row has this field of tuple?
All the data within the "fid" field like (119010, 208314436, 0), this is the first row,,, @cyang-kth
All the fid should be integer. Can you provide more details about how this field looks like?
I'm still follow your example I didn't change anything (example of "Stockholm, Sweden") @cyang-kth
@cyang-kth All the fid should be integer. Can you provide more details about how this field looks like?,,,, it's not clear for me, did you mean some rows may contain null values or float?
Try to replace the above line with
import numpy as np
gdf_edges["fid"] = np.arange(gdf_edges.shape[0])
See if you can save it successfully.
@cyang-kth
saved successfully, but when i moved to fmm notebook i faced other error
network = Network("stockholm/edges.shp","fid", "u", "v") print "Nodes {} edges {}".format(network.get_node_count(),network.get_edge_count()) graph = NetworkGraph(network)
the error is :
RuntimeErrorTraceback (most recent call last)
Check the fields of the shapefile to see if you have fid and u, v fields.
@cyang-kth import geopandas as gp shp = gp.GeoDataFrame.from_file("stockholm/edges.shp") print (shp)
the output:
u v key osmid \
0 119010 208314436 0 8019936
1 119010 119011 0 41506578
2 119011 5172054123 0 [28274898, 25666151, 28274837, 299998023]
3 119011 21760826 0 299988378
4 119013 21760821 0 [276290333, 276290332, 19874181]
... ... ... ... ...
94552 8309055931 264226559 0 48452302
94553 8309055931 1473546234 0 893985416
94554 8309055955 111722354 0 37480274
94555 8309055955 629493511 0 893985447
94556 8309055972 2323935087 0 23138796
oneway name \
0 1 Rålambsvägen
1 1 Västerbroplan
2 1 ['Långholmsgatan', 'Västerbroplan', 'Västerbron']
3 1 Västerbroplan
4 1 Västerbronedfarten
... ... ...
94552 0 Mjölnergatan
94553 1 Mjölnergatan
94554 0 Östra Galaxvägen
94555 1 Östra Galaxvägen
94556 0 Voltgatan
highway maxspeed length lanes bridge ref junction \
0 tertiary 40 149.451 None None None None
1 secondary 40 45.518 3 None None None
2 secondary ['40', '60'] 1284.467 3 yes None None
3 secondary 40 68.854 None None None None
4 secondary 40 363.530 None None None None
... ... ... ... ... ... ... ...
94552 unclassified None 15.907 None None None None
94553 unclassified None 38.737 None None None None
94554 residential 50 55.572 None None None None
94555 residential 50 43.040 None None None None
94556 unclassified 50 200.667 None None None None
tunnel access width service fid \
0 None None None None 0
1 None None None None 1
2 None None None None 2
3 None None None None 3
4 None None None None 4
... ... ... ... ... ...
94552 None None None None 94552
94553 None None None None 94553
94554 None None None None 94554
94555 None None None None 94555
94556 None None None None 94556
geometry
0 LINESTRING (18.02141 59.32853, 18.02127 59.328...
1 LINESTRING (18.02141 59.32853, 18.02132 59.328...
2 LINESTRING (18.02130 59.32815, 18.02139 59.328...
3 LINESTRING (18.02130 59.32815, 18.02153 59.328...
4 LINESTRING (18.02387 59.32727, 18.02378 59.327...
... ...
94552 LINESTRING (17.82677 59.61538, 17.82701 59.61545)
94553 LINESTRING (17.82677 59.61538, 17.82649 59.615...
94554 LINESTRING (17.82061 59.61569, 17.82046 59.61520)
94555 LINESTRING (17.82061 59.61569, 17.82079 59.616...
94556 LINESTRING (17.86802 59.61850, 17.86759 59.61671)
[94557 rows x 19 columns]
Please pull the latest master version to see which field is not found in the new error message.
@cyang-kth Really helpful, thanks a lot, it works fine and now everything going well....!!!
Let me say thanks for your very great and helpful work (Fast map matching algorithm), I am try to using it in Ubuntu operating system. First off all, when I go to implement the example of ("Stockholm, Sweden") in (../osmnx_example/download_network.ipynb) here, I am receiving an error as following:
bounds = (18.029122582902115, 18.070836297501724, 59.33476653724975, 59.352622230576124) x1,x2,y1,y2 = bounds boundary_polygon = Polygon([(x1,y1),(x2,y1),(x2,y2),(x1,y2)]) G = ox.graph_from_polygon(boundary_polygon, network_type='drive') start_time = time.time() save_graph_shapefile_directional(G, filepath='./stockholm') print("--- %s seconds ---" % (time.time() - start_time))
The error:`--------------------------------------------------------------------------- ValueError Traceback (most recent call last)