gpt4 book ai didi

Python - 使用 Osmnx 包获取 "TypeError: argument of type ' CRS' 不可迭代

转载 作者:太空宇宙 更新时间:2023-11-03 19:43:11 24 4
gpt4 key购买 nike

我在 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

最佳答案

看起来像 Geopandas 0.7 updated他们的 CRS 对象类型是 pyproj.CRS 而不是字符串。 osmnet图书馆也遇到了类似的问题。

您可以通过恢复到旧版本的 geopandas 来解决此问题:

conda install geopandas=0.6.3 -c conda-forge

也许还可以向 osmnx 开发人员提交错误报告!

关于Python - 使用 Osmnx 包获取 "TypeError: argument of type ' CRS' 不可迭代,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60312055/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com