最近我第一次使用Python的Basemap库,昨天我成功地在一个大约有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()
有人有线索吗?也许数组中有一个数据值不正确?
np.where
返回的是一个数组,但它应该返回一个单一的值。你的longitude
和latitude
数组的形状是什么? - Alyssa Haroldsen