本文介绍了使用python底图和pyproj运行时错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Spyder IDE和mpl_toolkits底图编写了一个脚本,将GPS轨迹绘制为箭头,以箭头标出速度着色的方向.一切正常,直到我将熊猫升级到0.13.数据是这样的:

I wrote a script using Spyder IDE with mpl_toolkits basemap to plot a GPS track as arrows for direction colored by speed. Everything worked fine until I upgraded pandas to 0.13. The data is like this:

                            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)

现在,当我尝试运行此行时:

Now when I try to run this line:

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争论,它将运行但不显示数据.任何想法有什么问题吗?

If I remove the latlon=True arguement it runs but does not display the data. Any ideas what is wrong?

推荐答案

无论出于何种原因,Basemap.quiver都不喜欢在升级后获取Pandas DataFrame列.我更改了:gMap.quiver(AllPoints ['lon'],AllPoints ['lat'] ....)到:gMap.quiver(AllPoints ['lon'].values,AllPoints ['lat'].values ....)现在可以正常工作了.

For whatever reason, Basemap.quiver doesn't like taking Pandas DataFrame columns after upgrading. I changed: gMap.quiver(AllPoints['lon'],AllPoints['lat']....)to: gMap.quiver(AllPoints['lon'].values,AllPoints['lat'].values....)and it works fine now.

这篇关于使用python底图和pyproj运行时错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 20:59