cartagen.kmeans_aggregation

cartagen.kmeans_aggregation#

kmeans_aggregation(points, ratio, column=None)#

Reduce a set of points by aggregation using K-Means clustering.

For each K-Means cluster calculated depending on the ratio, the centroid is calculated.

For more information about K-Means clustering, here is a link to the related wikipedia article

Parameters:
  • points (GeoDataFrame of Point) – The points to reduce.

  • ratio (float) – A value between 0 (all points are removed) and 1 (all points are kept).

  • column (str, optional) – Name of a numeric column to calculate the sum and mean.

Returns:

points (GeoDataFrame of Point) – A new set of points representing the centroids with:

  • ’cluster_count’: The number of points in the K-Means cluster represented by this point.

  • ’column_total’: The sum of the column values if provided.

  • ’column_mean’: The mean of the column values if provided.

See also

kmeans_selection

Reduce a set of points by selection using K-Means clustering.

kmeans_simplification

Reduce a set of points by simplification using K-Means clustering.

(Source code)

../_images/kmeans_aggregation.png