When working with multiple spatial datasets – especially multiple polygon or line datasets – users often wish to create new shapes based on places where those datasets overlap (or don’t overlap). These manipulations are often referred using the language of sets – intersections, unions, and differences. These types of operations are made available in the geopandas library through the overlay()
method.
在处理多个空间数据集(尤其是多个多边形或线数据集)时,用户通常希望根据这些数据集重叠(或不重叠)的地方创建新形状。这些操作通常使用集合的语言来引用——交集、并集和差异。这些类型的操作通过 overlay() 方法在 geopandas 库中可用。
The basic idea is demonstrated by the graphic below but keep in mind that overlays operate at the DataFrame level, not on individual geometries, and the properties from both are retained. In effect, for every shape in the left GeoDataFrame
, this operation is executed against every other shape in the right GeoDataFrame
:
基本思想如下图所示,但请记住,叠加在 DataFrame 级别运行,而不是在单个几何图形上运行,并且两者的属性都会保留。实际上,对于左侧 GeoDataFrame 中的每个形状,都会针对右侧 GeoDataFrame 中的每个其他形状执行此操作:
Note:
Note to users familiar with the shapely library: overlay()
can be thought of as offering versions of the standard shapely set-operations that deal with the complexities of applying set operations to two GeoSeries. The standard shapely set-operations are also available as GeoSeries
methods.熟悉 shapely 库的用户请注意:overlay() 可以被认为是提供标准 shapely 集合操作的版本,这些操作处理将集合操作应用于两个 GeoSeries 的复杂性。标准的 shapely 集合操作也可用作 GeoSeries 方法。