Skip to content

Commit

Permalink
fixes #1251
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Aug 24, 2023
1 parent b18d1b3 commit d068d3d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/zonal.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ setMethod("zonal", signature(x="SpatRaster", z="SpatRaster"),
} else {
sdf <- x@pnt$zonal(z@pnt, grast@pnt, txtfun, na.rm, opt)
}
messages(sdf, "zonal")
sdf <- messages(sdf, "zonal")
out <- .getSpatDF(sdf)
nz <- 1
if (group) {
Expand Down Expand Up @@ -151,8 +151,10 @@ setMethod("zonal", signature(x="SpatRaster", z="SpatRaster"),
} else if (nz == 1){
nls <- as.character(1:nlyr(x))
colnames(out)[-1] <- nls
if (colnames(out)[1] == "layer") colnames(out)[1] <- "zone"
out <- stats::reshape(out, direction="long", varying=nls, timevar="layer",v.names="value")
out <- out[, c(2,1,3)]
rownames(out) <- NULL
}
out
}
Expand Down

0 comments on commit d068d3d

Please sign in to comment.