Cartopy和matplotlib TypeError:不可用类型:' MultiLineString'

时间:2015-10-25 21:28:17

标签: python matplotlib cartopy

我试图通过官方Cartopy网站提供的示例尝试与Cartopy玩一下。所有这些都正常工作,但第一次

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

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

plt.show()

所有行都正常工作,但是一旦运行plt.show()命令,我就会收到以下错误消息:

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'

有人已经知道了吗? 我的matplotlib版本是1.4.2,而Cartopy版本是0.13.0

非常感谢您的帮助。

1 个答案:

答案 0 :(得分:4)

这是在https://github.com/SciTools/cartopy/issues/682的Cartopy问题跟踪器上报告的问题。基本上,Shapely在1.5.12和1.5.13之间改变了几何的可行性。在我们推出新版本的软件之前,解决方法是将您的安装版本降级为1.5.12。

HTH