gpt4 book ai didi

python - 使用 python basemap 和 pyproj 时出现运行时错误?

转载 作者:行者123 更新时间:2023-11-28 20:06:17 26 4
gpt4 key购买 nike

我使用带有 mpl_toolkits basemap 的 Spyder IDE 编写了一个脚本,将 GPS 轨迹绘制为按速度着色的方向箭头。在我将 pandas 升级到 0.13 之前一切正常。数据是这样的:

                            lon        lat     bearing  speed m/s
2014-01-20 16:26:00 -170.681264 -14.290060 NaN NaN
2014-01-20 16:27:00 -170.681259 -14.290074 163.753636 0.026727
2014-01-20 16:28:00 -170.681259 -14.290074 180.000000 0.001172
2014-01-20 16:29:00 -170.681259 -14.290077 180.000000 0.004981
ll = [-14.294238,-170.683732] 
ur = [-14.286362, -170.673260]
gMap = Basemap(projection='merc', resolution='f',
llcrnrlon=ll[1], llcrnrlat=ll[0],
urcrnrlon=ur[1], urcrnrlat=ur[0],ax=ax)

现在,当我尝试运行这一行时:

gMap.quiver(AllPoints['lon'],AllPoints['lat'],sin(radians(AllPoints['bearing'])),cos(radians(AllPoints['bearing'])),latlon=True,color=Points['speed m/s'].values,scale=40,cmap=plt.cm.rainbow)

我收到这个错误:

Traceback (most recent call last):  File "", line 1, in   File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py", line 559, in with_transform    x, y = self(x,y)  File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py", line 1148, in __call__    xout,yout = self.projtran(x,y,inverse=inverse)  File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\proj.py", line 286, in __call__    outx,outy = self._proj4(x, y, inverse=inverse)  File "C:\Python27\lib\site-packages\mpl_toolkits\basemap\pyproj.py", line 388, in __call__    _proj.Proj._fwd(self, inx, iny, radians=radians, errcheck=errcheck)  File "_proj.pyx", line 124, in _proj.Proj._fwd (src/_proj.c:1594)RuntimeError

如果我删除 latlon=True 参数,它会运行但不会显示数据。有什么想法吗?

最佳答案

无论出于何种原因,Basemap.quiver 都不喜欢在升级后采用 Pandas DataFrame 列。我改变了:gMap.quiver(AllPoints['lon'],AllPoints['lat']...)至:gMap.quiver(AllPoints['lon'].values,AllPoints['lat'].values....)现在工作正常。

关于python - 使用 python basemap 和 pyproj 时出现运行时错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23550820/

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