Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Dec 26, 2023
1 parent f870298 commit aa0060d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion R/k_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ setMethod("k_means", signature(x="SpatRaster"),
function(x, centers=3, ..., maxcell=1000000, filename="", overwrite=FALSE, wopt=list()) {
stopifnot(maxcell > 0)
if (ncell(x) <= maxcell) {
v <- unique(na.omit(as.matrix(x)))
v <- values(x)
omit <- as.vector(attr(v, "na.action"))
km <- stats::kmeans(v, centers=centers, ...)
out <- rast(x, nlyr=1)
Expand Down

0 comments on commit aa0060d

Please sign in to comment.