python底图中的ValueError?

时间:2015-08-05 17:26:16

标签: python matplotlib-basemap

所以我最近刚刚第一次使用python的底图,而且昨天我有一个脚本可以处理大约30,000点的大型数据集。当我今天回来时,它停止了工作,并在添加新数据集时开始给我价值错误。我不知道是什么导致它,但我得到一个值错误?

    ---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-16fa79cd74a5> in <module>()
     12     longitude = np.array(df[(df['FLOAT'] == x)]['LONGITUDE'])
     13     latitude = np.array(df[df['FLOAT'] == x]['LATITUDE'])
---> 14     m.plot(longitude,latitude, latlon=True)
     15 parallels = np.arange(-90.,90.,10.)
     16 

C:\Anaconda\lib\site-packages\mpl_toolkits\basemap\__init__.pyc in with_transform(self, x, y, *args, **kwargs)
    534             if self.projection in _cylproj or self.projection in _pseudocyl:
    535                 if x.ndim == 1:
--> 536                     x = self.shiftdata(x)
    537                 elif x.ndim == 0:
    538                     if x > 180:

C:\Anaconda\lib\site-packages\mpl_toolkits\basemap\__init__.pyc in shiftdata(self, lonsin, datain, lon_0)
   4775             thresh = 360.-londiff_sort[-2]
   4776             itemindex = len(lonsin)-np.where(londiff>=thresh)[0]
-> 4777             if itemindex:
   4778                 # check to see if cyclic (wraparound) point included
   4779                 # if so, remove it.

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

有人有线索吗?也许数组中的数据值无法正常工作?

1 个答案:

答案 0 :(得分:2)

这是由basemap bug #214引起的。

在撰写本文时(2016-03-17),此错误仍然存​​在,因此您需要找到解决方法:

  • 在绘图之前对数据进行排序。当然,如果您需要绘制实际的线段,这可能是不可取的。
  • 在子部分中拆分数据,例如你已经完成的。