Skip to content

Commit

Permalink
Merge pull request #1317 from kadyb/master
Browse files Browse the repository at this point in the history
small fixes for `k_means()`
  • Loading branch information
rhijmans authored Oct 18, 2023
2 parents e240872 + fa5084c commit 750a79b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/k_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions man/k_means.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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}}}
}
Expand Down

0 comments on commit 750a79b

Please sign in to comment.