diff --git a/R/k_means.R b/R/k_means.R index 0d478bead..37df3521d 100644 --- a/R/k_means.R +++ b/R/k_means.R @@ -27,7 +27,7 @@ setMethod("k_means", signature(x="SpatRaster"), } v <- na.omit(spatSample(x, maxcell, "regular")) km <- kmeans(v, centers=centers, ...) - r <- predict(logo, km, fun=pkmeans, na.rm=TRUE, filename=filename, overwrite=overwrite, wopt=wopt) + r <- predict(x, km, fun=pkmeans, na.rm=TRUE, filename=filename, overwrite=overwrite, wopt=wopt) } r } diff --git a/man/k_means.Rd b/man/k_means.Rd index 08b61343c..4fb4f7c9b 100644 --- a/man/k_means.Rd +++ b/man/k_means.Rd @@ -8,7 +8,7 @@ \title{k_means} \description{ -Compute kmeans clusters for a SpatRaster. For large SpatRasters (with \code{ncell(x) > maxcell}) this is done in two steps. First a sample of the cells is used to compute the cluster centers. Then each cell is assigned to a cluster by computing the distance to these centers. +Compute k-means clusters for a SpatRaster. For large SpatRasters (with \code{ncell(x) > maxcell}) this is done in two steps. First a sample of the cells is used to compute the cluster centers. Then each cell is assigned to a cluster by computing the distance to these centers. } \usage{ @@ -20,7 +20,7 @@ Compute kmeans clusters for a SpatRaster. For large SpatRasters (with \code{ncel \item{centers}{either the number of clusters, or a set of initial (distinct) cluster centres. If a number, a random set of (distinct) cells in \code{x} is chosen as the initial centres} \item{...}{additional arguments passed to \code{\link[stats]{kmeans}}} \item{maxcell}{positive integer. The size of the regular sample used if it is smaller than \code{ncell(x)}} - \item{filename}{character. Output filename (ignored if \code{as.raster=FALSE}} + \item{filename}{character. Output filename (ignored if \code{as.raster=FALSE})} \item{overwrite}{logical. If \code{TRUE}, \code{filename} is overwritten} \item{wopt}{list with additional arguments for writing files as in \code{\link{writeRaster}}} }