Page Summary
-
The algorithm performs K-Means clustering on the input image.
-
The output is a single-band image showing the cluster ID for each pixel.
-
Clustering can be applied to non-overlapping grid cells or overlapping tiles.
-
Clusters spanning cell or tile boundaries may receive different labels in each section.
| Usage | Returns |
|---|---|
ee.Algorithms.Image.Segmentation.KMeans(image, numClusters
, numIterations
, neighborhoodSize
, gridSize
, forceConvergence
, uniqueLabels
)
|
Image |
| Argument | Type | Details |
|---|---|---|
image
|
Image | The input image for clustering. |
numClusters
|
Integer, default: 8 | Number of clusters. |
numIterations
|
Integer, default: 20 | Number of iterations. |
neighborhoodSize
|
Integer, default: 0 | Neighborhood size. The amount to extend each tile (overlap) when computing the clusters. This option is mutually exclusive with gridSize. |
gridSize
|
Integer, default: null | Grid cell-size. If greater than 0, kMeans will be run independently on cells of this size. This has the effect of limiting the size of any cluster to be gridSize or smaller. This option is mutually exclusive with neighborhoodSize. |
forceConvergence
|
Boolean, default: false | If true, an error is thrown if convergence is not achieved before numIterations. |
uniqueLabels
|
Boolean, default: true | If true, clusters are assigned unique IDs. Otherwise, they repeat per tile or grid cell. |

