我正在尝试执行以下代码:
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'
有人可以帮我修复它吗?
答案 0 :(得分:0)
这是您的pyproj安装出现的问题。如果您遵循OSMnx文档中的“如果遇到任何问题”安装说明,则应该对其进行修复(即pyproj在虚拟环境中更可靠):https://osmnx.readthedocs.io/en/stable/#installation
此处讨论并解决了该问题:https://github.com/gboeing/osmnx/issues/203