I´m using the lidR
(Version 4.0.0) package to clip a LAScatalog
(with 119 .las files, ~52.9 Gb) using a very large polygon shapefile (~865K buffers with 25m diameter each). I´m stuck in this task because when I run the process without parallelization, the function estimates ~27 days to finish the process. I already tried to parallelize, using plan(multissesion)
from future
package, but the estimated time to finish the task is even much higher than without parallelization. What I've noticed, and what's intriguing me, is that as time goes by, the time taken to produce a las file clipped per polygon increases. For example, when I start the process, I can produce 244 clipped las files per minute, but after one hour this number decreases to ~120/minute, and after 24 hours to 12/minute.
I was wondering if there is a more efficient way to accomplish this task.
Here is my R session and code:
#> R version 4.1.3 (2022-03-10) -- "One Push-Up"
#> Copyright (C) 2022 The R Foundation for Statistical Computing
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
# i) create a lascatalog;
catalog_las<- readLAScatalog(outdir)
opt_independent_files(catalog_las)<- TRUE
opt_merge(catalog_las) = FALSE
# ii) Indexation of the points with lax files
lidR:::catalog_laxindex(catalog_las)
# iii) multiple extraction on disk to write the resulted clipped las files to disk
shp_path="C:/SIG_project/tests"# path to the polygon shapefile
polygons <- sf::st_read(paste0(shp_path, "//buffers.shp"),quiet = TRUE)
opt_output_files(catalog_las) <- paste0(getwd(), "_{rand_point}") # to designate the path where one las file per "rand_point" ID will be written
clip_roi(catalog_las, polygons) # to clip the las files at the buffers boundaries