diff --git a/R/extract.R b/R/extract.R index 62adad7c0..3f6a76a0b 100644 --- a/R/extract.R +++ b/R/extract.R @@ -187,6 +187,7 @@ extract_fun <- function(x, y, fun, ID=TRUE, weights=FALSE, exact=FALSE, touches= } if (bind) { if (nrow(e) == nrow(y)) { + e <- data.frame(e) e <- cbind(y, e) } else { #? can this occur? @@ -213,7 +214,6 @@ do_fun <- function(e, fun, ...) { if (length(cn) == ncol(e)) { colnames(e) <- cn } - e <- data.frame(e) } e } @@ -312,6 +312,7 @@ function(x, y, fun=NULL, method="simple", cells=FALSE, xy=FALSE, ID=TRUE, weight if (bind) { if (nrow(e) == nrow(y)) { + e <- data.frame(e) e <- cbind(y, e[,-1,drop=FALSE]) } else { warn("extract", "cannot return a SpatVector because the number of records extracted does not match the number of rows in y (perhaps you need to use a summarizing function") diff --git a/man/expanse.Rd b/man/expanse.Rd index 701019ae4..574a3d095 100644 --- a/man/expanse.Rd +++ b/man/expanse.Rd @@ -16,7 +16,8 @@ For vector data, the best way to compute area is to use the longitude/latitude C } \usage{ -\S4method{expanse}{SpatRaster}(x, unit="m", transform=TRUE, byValue=FALSE, zones=NULL, wide=FALSE, usenames=FALSE) +\S4method{expanse}{SpatRaster}(x, unit="m", transform=TRUE, byValue=FALSE, + zones=NULL, wide=FALSE, usenames=FALSE) \S4method{expanse}{SpatVector}(x, unit="m", transform=TRUE) } diff --git a/man/zonal.Rd b/man/zonal.Rd index 7b472ab56..8fd71d139 100644 --- a/man/zonal.Rd +++ b/man/zonal.Rd @@ -21,8 +21,8 @@ You can also summarize values of a SpatVector for each polygon (zone) defined by as.raster=FALSE, filename="", overwrite=FALSE, wopt=list()) \S4method{zonal}{SpatRaster,SpatVector}(x, z, fun="mean", na.rm=FALSE, w=NULL, weights=FALSE, - exact=FALSE, touches=FALSE, small=TRUE, as.raster=FALSE, as.polygons=FALSE, wide=TRUE, - filename="", wopt=list()) + exact=FALSE, touches=FALSE, small=TRUE, as.raster=FALSE, as.polygons=FALSE, + wide=TRUE, filename="", wopt=list()) \S4method{zonal}{SpatVector,SpatVector}(x, z, fun=mean, ..., weighted=FALSE, as.polygons=FALSE) }