mrvaita
mrvaita

Reputation: 103

Cartopy and matplotlib TypeError: unhashable type: 'MultiLineString'

I'm trying to play around a bit with Cartopy by following the examples offered in the official Cartopy website. All of them work correctly but the first

import cartopy.crs as ccrs
import matplotlib.pyplot as plt

ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines()

plt.show()

All the lines work correctly but as soon as I run the plt.show() command I get the following error message:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1539, in __call__
    return self.func(*args)
  File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 278, in resize
    self.show()
  File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 349, in draw
    FigureCanvasAgg.draw(self)
  File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_agg.py", line 469, in draw
    self.figure.draw(self.renderer)
  File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1079, in draw
    func(*args)
  File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/mrvaita/python_workspace/gis_venv/local/lib/python2.7/site-packages/cartopy/mpl/geoaxes.py", line 359, in draw
    inframe=inframe)
  File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 2092, in draw
    a.draw(renderer)
  File "/usr/lib/python2.7/dist-packages/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/mrvaita/python_workspace/gis_venv/local/lib/python2.7/site-packages/cartopy/mpl/feature_artist.py", line 113, in draw
    {})
  File "/usr/lib/python2.7/weakref.py", line 433, in setdefault
    return self.data.setdefault(ref(key, self._remove),default)
TypeError: unhashable type: 'MultiLineString'

Does someone already know anything about that? My matplotlib version is 1.4.2 and the Cartopy version is 0.13.0

Thank you very much in advance for the help.

Upvotes: 1

Views: 1022

Answers (1)

pelson
pelson

Reputation: 21849

This was an issue reported on the Cartopy issue tracker at https://github.com/SciTools/cartopy/issues/682. Basically, Shapely changed the hashability of a geometry between 1.5.12 and 1.5.13. The workaround, until we have a new release of cartopy, is to downgrade your installation of shapely to 1.5.12.

HTH

Upvotes: 4

Related Questions