Geometry must be a Point or LineString 错误使用Cartopy

Geometry must be a Point or LineString error using Cartopy

我正在尝试 运行 一个简单的 Cartopy 示例:

   import cartopy.crs as ccrs
   import matplotlib.pyplot as plt
   ax = plt.axes(projection=ccrs.PlateCarree())
   ax.coastlines()
   plt.show()

但是我收到了这个错误:

几何必须是点或线串
python: geos_ts_c.cpp:4179: int GEOSCoordSeq_getSize_r(GEOSContextHandle_t, const geos::geom::CoordinateSequence*, unsigned int*): Assertion0 != cs' 失败`。

我使用 miniconda3 安装了 Cartopy:conda install -c conda-forge cartopy 我也尝试用 pip 安装 Cartopy(在虚拟环境中),但我得到了同样的错误。 我的 OS 是 Debian Buster。

有什么想法吗?

问题是 shapely 的版本错误,不应使用 Cartopy 二进制包,而应从源代码构建它。 这是解释 here and here.

所以我做了:

pip uninstall shapely
pip install shapely --no-binary shapely