我尝试从momepy(https://github.com/pysal/momepy/blob/main/docs/user_guide/getting_started.ipynb)执行此练习,但在第三个代码块上
f, ax = plt.subplots(figsize=(10, 10))
buildings.plot(ax=ax)
ax.set_axis_off()
plt.show()
我得到了以下错误
AttributeError Traceback (most recent call last)
Cell In[12], line 5
1 buildings = gpd.read_file(momepy.datasets.get_path('bubenec'),
2 layer='buildings')
4 f, ax = plt.subplots(figsize=(10, 10))
----> 5 buildings.plot(ax=ax)
6 ax.set_axis_off()
7 plt.show()
File ~/miniconda3/envs/testbed/lib/python3.10/site-packages/geopandas/plotting.py:925, in GeoplotAccessor.__call__(self, *args, **kwargs)
923 kind = kwargs.pop("kind", "geo")
924 if kind == "geo":
--> 925 return plot_dataframe(data, *args, **kwargs)
926 if kind in self._pandas_kinds:
927 # Access pandas plots
928 return PlotAccessor(data)(kind=kind, **kwargs)
File ~/miniconda3/envs/testbed/lib/python3.10/site-packages/geopandas/plotting.py:689, in plot_dataframe(df, column, cmap, color, ax, cax, categorical, legend, scheme, k, vmin, vmax, markersize, figsize, legend_kwds, categories, classification_kwds, missing_kwds, aspect, **style_kwds)
686 markersize = df[markersize].values
688 if column is None:
--> 689 return plot_series(
690 df.geometry,
691 cmap=cmap,
692 color=color,
...
---> 67 geom = shapely.geos.lgeos.GEOSGeom_clone(geom._ptr)
68 return shapely.geometry.base.geom_factory(geom)
70 # fallback going through WKB
AttributeError: module 'shapely.geos' has no attribute 'lgeos'
不完全确定是否缺少模块或是否存在库不兼容
1条答案
按热度按时间im9ewurl1#
在shapely的新版本(2022年12月12日发布的2.0.0)中,没有属性“lgeos”。
文件链接:
https://pypi.org/project/Shapely/#history
您可以通过以下方式检查版本:
如果要在代码中使用
lgeos
,可以将版本降级为1.8.5
我能够在Jupyter的1.8.5版本上成功导入。