【发布时间】:2020-06-04 07:31:28
【问题描述】:
我在使用 Osmnx 时遇到了一个奇怪的类型错误,我无法找到任何其他线程或信息。我过去曾在另一台机器上使用过这个库,并且通过全新的 Anaconda 安装和全新的 osmnx 安装,我在传递“crs”时遇到类型错误。
我最初甚至在导入包时遇到了这个用户遇到的问题:Cannot import name 'CRS' from 'pyproj' for using the osmnx library
我安装了一个较旧的 (.11) 版本和所需的包,现在 osmnx 可以正常导入,但甚至使用示例代码:
import osmnx as ox
G = ox.graph_from_place('Los Angeles, California', network_type='drive')
ox.plot_graph(G)
给出错误
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-15-2b688bf77702> in <module>
2 graph = ox.gdf_from_place(place_name)
3 ox.save_gdf_shapefile(city)
----> 4 city = ox.project_gdf(city)
5 fig, ax = ox.plot_shape(city, figsize=(3,3))
~\Anaconda3\lib\site-packages\osmnx\projection.py in project_gdf(gdf, to_crs, to_latlong)
98 # else, project the gdf to UTM
99 # if GeoDataFrame is already in UTM, just return it
--> 100 if (gdf.crs is not None) and ('+proj=utm ' in gdf.crs):
101 return gdf
102
TypeError: argument of type 'CRS' is not iterable
我想我已经彻底潜伏了足够多的线程,以相信这是一个基于我的安装的新问题,但任何帮助将不胜感激。
相关版本
pyproj 2.4.2.post1
osmnx .11
rtree .9.4
geopandas .7.0
【问题讨论】:
-
这个问题可以通过根据其文档安装instructions 安装 OSMnx 来避免。另见stackoverflow.com/a/62958055/7321942