Spatial data are often more granular than we need. For example, we might have data on sub-national units, but we’re actually interested in studying patterns at the level of countries.
空间数据通常比我们需要的更细化。例如,我们可能有地方单位的数据,但实际上我们对研究国家层面的内容很感兴趣。
In a non-spatial setting, when all we need are summary statistics of the data, we aggregate our data using the groupby()
function. But for spatial data, we sometimes also need to aggregate geometric features. In the geopandas library, we can aggregate geometric features using the dissolve()
function.
在非空间环境中,我们使用 groupby() 函数聚合数据。但是对于空间数据,我们有时也需要聚合几何特征。在 geopandas 库中,我们可以使用 dissolve() 函数聚合几何特征。
dissolve()
can be thought of as doing three things:
dissolve()可以被认为是在做三件事。
- it dissolves all the geometries within a given group together into a single geometric feature (using the
unary_union
method), and.它将给定组中的所有几何图形分解为单个几何特征(使用 unary_union 方法),并且 - it aggregates all the rows of data in a group using groupby.aggregate, and.它使用 groupby.aggregate 聚合组中的所有数据行。
- it combines those two results.它将这两个结果结合起来。