【发布时间】:2021-12-08 05:17:57
【问题描述】:
我正在尝试使用 Google Colab 上的 gdf.overlay 函数与 2 GeoDataFrame 进行交集。请看下面的代码
!sudo apt install libspatialindex-dev
!sudo pip3 install rtree
!pip install pygeos
overlap = gpd.overlay(gdf1,gdf2, how='intersection')
overlap.plot(figsize=(10,10), cmap='jet')
我收到以下错误消息
ImportError: Spatial indexes require either `rtree` or `pygeos`. See installation instructions at https://geopandas.org/install.html
是什么导致了这里的问题?
【问题讨论】:
-
您同时使用了
pip和pip3。他们可能在不同的 python 安装上运行 -
使用
conda安装rtree并使用conda-forge将您的python 更新为cpython。 -
尝试使用 venv (
python3 -mvenv your-virtual-env),然后避免(总是!)sudo pip。 pip 安装包,一旦你激活了我们的虚拟环境,应该以更可靠的方式产生一个连贯的库生态系统。
标签: python google-colaboratory geopandas