rkmeans | R Documentation |
This function allows to classify satellite images using k-means.
rkmeans(
img,
k,
iter.max = 100,
nstart = 50,
algo = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen"),
verbose = FALSE,
...
)
img |
RasterStack or RasterBrick |
k |
the number of clusters |
iter.max |
The maximum number of iterations allowed |
nstart |
if centers is a number, how many random sets should be chosen? |
algo |
It can be "Hartigan-Wong", "Lloyd", "Forgy" or "MacQueen". See kmeans |
verbose |
This paramater is Logical. It Prints progress messages during execution. |
... |
Options to be passed to the function. See kmeans |
In principle, this function allows to classify satellite images specifying
a k
value, however it is recommended to find the optimal value of k
using
the calkmeans function.
If warnings such as "Quick-TRANSfer stage steps exceeded maximum" or
"did not converge in 10 iterations" are obtained, it will be necessary to increase the
iterations in 20 or 30 (i.e., inter.max = 20
or iter.max = 30
). This issue is usually
obtained with "Hartigan-Wong". See details of kmeans.
Gareth James, Daniela Witten, Trevor Hastie, Robert Tibshirani. (2013). An introduction to statistical learning : with applications in R. New York: Springer.
library(ForesToolboxRS)
# Load the dataset
data(img_l8)
# Select the best embedded algorithm in kmeans
classKmeans <- rkmeans(img = img_l8, k = 4, algo = "MacQueen")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.