Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Mar 11, 2024
1 parent 700852c commit 8a357f9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -213,7 +214,6 @@ do_fun <- function(e, fun, ...) {
if (length(cn) == ncol(e)) {
colnames(e) <- cn
}
e <- data.frame(e)
}
e
}
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion man/expanse.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions man/zonal.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 8a357f9

Please sign in to comment.