我正在尝试执行以下代码:

import osmnx as ox
G = ox.graph_from_place('Manhattan Island, New York City, New York, USA', network_type='drive')
ox.plot_graph(ox.project_graph(G))


但我得到此错误输出:



runfile('C:/Users/username/AppData/Local/Continuum/anaconda3/pkgs/osmnx-0.8.2-py_0/site-packages/osmnx/Isochrones 1.py', wdir='C:/Users/username/AppData/Local/Continuum/anaconda3/pkgs/osmnx-0.8.2-py_0/site-packages/osmnx')

Traceback (most recent call last):

  File "<ipython-input-21-48f64135d3f9>", line 1, in <module>
    runfile('C:/Users/username/AppData/Local/Continuum/anaconda3/pkgs/osmnx-0.8.2-py_0/site-packages/osmnx/Isochrones 1.py', wdir='C:/Users/username/AppData/Local/Continuum/anaconda3/pkgs/osmnx-0.8.2-py_0/site-packages/osmnx')

  File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/username/AppData/Local/Continuum/anaconda3/pkgs/osmnx-0.8.2-py_0/site-packages/osmnx/Isochrones 1.py", line 15, in <module>
    graph = ox.graph_from_place(place_name, network_type='drive')

  File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\osmnx\core.py", line 1867, in graph_from_place
    custom_filter=custom_filter)

  File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\osmnx\core.py", line 1733, in graph_from_polygon
    polygon_utm, crs_utm = project_geometry(geometry=polygon)

  File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\osmnx\projection.py", line 53, in project_geometry
    gdf_proj = project_gdf(gdf, to_crs=to_crs, to_latlong=to_latlong)

  File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\osmnx\projection.py", line 119, in project_gdf
    projected_gdf = gdf.to_crs(utm_crs)

  File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\geopandas\geodataframe.py", line 443, in to_crs
    geom = df.geometry.to_crs(crs=crs, epsg=epsg)

  File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\geopandas\geoseries.py", line 304, in to_crs
    proj_in = pyproj.Proj(self.crs, preserve_units=True)

  File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\pyproj\__init__.py", line 358, in __new__
    return _proj.Proj.__new__(self, projstring)

  File "_proj.pyx", line 84, in _proj.Proj.__cinit__

RuntimeError: b'No such file or directory'




谁能帮我修复它?

最佳答案

pyproj安装出现问题。如果您遵循OSMnx文档中的“如果遇到任何问题”安装说明,则应该对其进行修复(即pyproj在虚拟环境中更可靠):https://osmnx.readthedocs.io/en/stable/#installation

在这里讨论并解决了该问题:https://github.com/gboeing/osmnx/issues/203

另请参见herehere

关于python - OSMNX RuntimeError:b'没有这样的文件或目录',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52758760/

10-12 23:21