/

K-means Clustering

Runs a simple unsupervised K-means clustering algorithm for classification.


Description

A processing block that creates a given number of clusters in an image and assigns each pixel to a cluster.

See this block on the marketplace.

How it works

This block can only process images with a maximum size of 1.2 GB, because the entire image is loaded at once into memory. Any image with a larger size will generate an error.

Nodata pixels in the input dataset aren't excluded during the clustering. If the nodata value has a large distance from all other pixels (measured by the Frobenius or L2 norm), all nodata pixels will likely form a separate cluster.

ParameterOverview
n_clustersinteger / required
The number of clusters for the K-means clustering and the number of classes in the output file. The default value is 6.
n_iterationsinteger / required
The number of iterations for the K-means clustering. The default value is 10.
n_sieve_pixelsinteger / required
The minimum number of pixels in each patch or group for the classification. The default value is 64.

Example

A workflow with SPOT 6/7 Display (Streaming).

{
  "oneatlas-spot-aoiclipped:1": {
    "bbox": null,
    "time": null,
    "limit": 3,
    "intersects": {
      "type": "Polygon",
      "coordinates": [
        [
          [18.42631, -33.912732],
          [18.420799, -33.922741],
          [18.44355, -33.924784],
          [18.441069, -33.913781],
          [18.42631, -33.912732]
        ]
      ]
    },
    "zoom_level": 17
  },
  "k-means-clustering:1": {
    "n_clusters": 6,
    "n_iterations": 10,
    "n_sieve_pixels": 64
  }
}

Capabilities

Input

Output

To know more please check the block capabilities specifications.