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

pixel_metrics cannot use a SpatRaster as a template #731

Open
candelas762 opened this issue Nov 21, 2023 · 0 comments
Open

pixel_metrics cannot use a SpatRaster as a template #731

candelas762 opened this issue Nov 21, 2023 · 0 comments
Assignees
Labels
Bug A bug in the package

Comments

@candelas762
Copy link

candelas762 commented Nov 21, 2023

To be able to use a raster as a template given the argument res, this raster can not be in a SpatRaster format. One sollution is simple and is to convert it to a RasterLayer with raster::raster().

This is a reproducible example to use the maximum height raster as a template for minimum heigh calculation:

library(lidR)

LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
ctg <- readLAScatalog(LASfile, select = "xyz", chunk_size = 140, chunk_buffer = 0)
opt_chunk_alignment(ctg) <- c(0,20)
plot(ctg, chunk = TRUE)

library(future)
plan(multisession, workers = 2)

m = pixel_metrics(ctg, ~max(Z), 20)
# Works
pixel_metrics(ctg, ~min(Z), m)
# Does not work
pixel_metrics(ctg, ~miin(Z), raster(m))
# Works
@Jean-Romain Jean-Romain self-assigned this Nov 21, 2023
@Jean-Romain Jean-Romain added the Bug A bug in the package label Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in the package
Projects
None yet
Development

No branches or pull requests

2 participants