Skip to content

Commit

Permalink
fixes #1133
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Apr 27, 2023
1 parent 287efa8 commit 9b62e9c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/zonal.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ setMethod("zonal", signature(x="SpatRaster", z="SpatRaster"),
nl <- nlyr(x)
nms <- names(x)
if (group) {
xzg <- c(grast, z, x)
v <- as.data.frame(xzg, na.rm=TRUE)
gzx <- c(grast, z, x)
v <- as.data.frame(gzx, na.rm=FALSE)
out <- stats::aggregate(v[,-c(1:2)], v[,1:2], fun, ...)
colnames(out)[-c(1:2)] <- nms
} else {
for (i in 1:nl) {
xz <- c(x[[i]], group, z)
v <- as.data.frame(xz, na.rm=TRUE)
xz <- c(x[[i]], z)
v <- as.data.frame(xz, na.rm=FALSE)
d <- stats::aggregate(v[,1], v[,2,drop=FALSE], fun, ...)
colnames(d)[2] <- nms[i]
if (i == 1) {
Expand Down

0 comments on commit 9b62e9c

Please sign in to comment.