-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
Make output of lasclip() a catalog() instead of a list() #266
Comments
Your requests makes a lot of sense however your first request already exists. library(lidR)
# Load a LAScatalog
LASfile <- system.file("extdata", "Megaplot.laz", package = "lidR")
ctg <- readLAScatalog(LASfile)
# Load the plot centers
plots = matrix(c(684800, 684850, 5017850, 5017900), ncol = 2)
plots = SpatialPointsDataFrame(plots, data.frame(NAME = c("P1", "P2")))
# Visual check
plot(ctg)
plot(plots, add = T)
# Set output_files option to write the results on disk
opt_output_files(ctg) <- paste0(tempdir(), "/{NAME}")
# new_ctg is a LAScatalog
new_ctg <- lasclip(ctg, plots, radius = 10)
plot(new_ctg) Notice that in the specific case of Your second requests is also pertinent however I cannot implement it for consistency reasons. Indeed what you are asking has a meaning only for the specific case of not wall-to-wall catalog of plots. But in the general case there is no meaning at computing However I can modify opt_chunk_buffer(new_ctg) <- 0
opt_chunk_size(new_ctg) <- 0
opt_filter(new_ctg) <- "-keep_first"
opt_output_files(new_ctg) <- ""
output <- catalog_apply(new_ctg, lasmetrics, func = .stdmetrics)
output <- data.table::rbindlist(output)
plots@data <- cbind(plot@data, output) This is equivalent to |
Done in |
this is great JR! thanks a lot! |
When processing the point cloud data to create wall-to-wall forest inventory layers, the first step is to calculate point cloud metrics for reference plots. It is a simple task that consist of several steps:
sf()
object)lasclip()
to clip point clouds to plot borderslasmetrics()
The issue here is that the output of
lasclip()
is alist()
. Therefore to calculate metrics we cannot uselasmetrics(clipped_plots, .stdmetrics)
, but rather calculate the metrics usinglapply
or a simple for loop. This is not consistent with other functions inlidR
, that in most cases accept either a single las file as input, or catalog.I suggest two changes:
lasclip
from alist()
to acatalog()
. This would allow to use functions like catalog_apply(), use multi-core processing etc. (all benefits of catalogs). Such catalog would not be a wall-to-wall object of course, and should processed file-by-file.lasmetrics()
to acceptcatalog()
as input. In that case the function would run on every plot returning an output similar togrid_metrics()
.The text was updated successfully, but these errors were encountered: