簡體   English   中英

Geopandas:如何在 geoandas 數據框之間進行空間連接?

[英]Geopandas: how to make spatial join between geoandas dataframes?

我有兩個 geopandas 數據框。 一個由多邊形組成,另一個由點組成。

grid.head()

                                            geometry  zone
0   POLYGON ((-71.11007 42.36766, -71.10957 42.367...   0
1   POLYGON ((-71.11007 42.36716, -71.10957 42.367...   1
2   POLYGON ((-71.11007 42.36666, -71.10957 42.366...   2
3   POLYGON ((-71.11007 42.36616, -71.10957 42.366...   3
4   POLYGON ((-71.11007 42.36566, -71.10957 42.365...   4

gdf.head()
                     geometry
0   POINT (-71.09000 42.36000)
1   POINT (-71.09000 42.36000)
2   POINT (-71.09477 42.36407)
3   POINT (-71.09000 42.36000)
4   POINT (-71.09477 42.36407)

如果我嘗試進行空間連接,則會出現錯誤

from geopandas import sjoin
gdf = sjoin(grid, gdf)

AttributeError: 'NoneType' object has no attribute 'intersection'

我試圖安裝rtree

sudo python3.7 -m pip install "rtree>=0.8,<0.9"

看起來gridgdf的幾何列中至少有一個條目是None sjoin需要對所有幾何圖形進行空間交叉,如果它們是None ,它就不能這樣做。

您可以檢查以下任何一項是否返回任何行:

grid[grid.geometry.isnull()]
gdf[gdf.geometry.isnull()]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM