如何使用 GeoPandas 执行空间查询?

How to perform a spatial query using GeoPandas?

我有两个 shapefile:意大利邮政编码;和意大利的市政当局。两者都是多边形格式,都包含每个相关形状的名称。我想向邮政编码 shapefile 添加一个邮政编码所在城市的字段。我相信这是一个空间查询。我如何使用 GeoPandas 执行此操作?

这样的空间查询可以通过GeoPandas的空间连接功能sjoin来完成。它看起来像:

res = geopandas.sjoin(postcodes, municipalities, op='contains')

其中 op 将取决于数据的特定空间关系。

有关更多信息,请参阅 https://geopandas.readthedocs.io/en/latest/mergingdata.html#spatial-joins