Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zonal()'s as.raster = TRUE does not work on some cases #348

Closed
Nowosad opened this issue Oct 2, 2021 · 0 comments
Closed

zonal()'s as.raster = TRUE does not work on some cases #348

Nowosad opened this issue Oct 2, 2021 · 0 comments

Comments

@Nowosad
Copy link
Contributor

Nowosad commented Oct 2, 2021

See the below reprex:

# remotes::install_github("nowosad/spData") #dev version of spData is required here
library(terra)
#> terra version 1.4.5
elev = rast(system.file("raster/elev.tif", package = "spData"))
grain = rast(system.file("raster/grain.tif", package = "spData"))

# works
z = zonal(elev, grain, fun = "mean", as.raster = FALSE)
z
#>   grain     elev
#> 1  clay 14.80000
#> 2  silt 21.15385
#> 3  sand 18.69231

# fails
z2 = zonal(elev, grain, fun = "mean", as.raster = TRUE)
#> Error in x@ptr$replaceValues(from, to, -1, opt): Not compatible with requested type: [type=character; target=double].
z2
#> Error in eval(expr, envir, enclos): object 'z2' not found

Created on 2021-10-02 by the reprex package (v2.0.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant