ValueError in python basemap?

So, this is my first time using a python basemap and yesterday I had a script that worked on a large dataset of about 30,000 points. When I came back today it stopped working and started giving me error values ​​when I added a new dataset. I don't know what might be causing this, but I am getting a value error?

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.)

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()


Who has the key? Maybe there is a data value in the array that is not working correctly?


source to share

1 answer

This is caused by basemap error # 214 .

At the time of writing (2016-03-17) this bug is still open, so you need to find a workaround:

  • Sorting data before plotting. Of course, this may not be desirable if you need to draw actual line segments.
  • Divide the data into subsections like you did.


All Articles