r-lidar / lidR

Airborne LiDAR data manipulation and visualisation for forestry application
https://CRAN.R-project.org/package=lidR
GNU General Public License v3.0
601 stars 131 forks source link

pixel_metrics significantely slower with terra #527

Closed Jean-Romain closed 2 years ago

Jean-Romain commented 2 years ago
library(lidR)
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
las <- readLAS(LASfile, select = "*", filter = "-keep_random_fraction 0.5")
system.time(pixel_metrics(las, .stdmetrics, res = 40, pkg = "raster"))
#> utilisateur     système      écoulé 
#>       0.327       0.008       0.298
system.time(pixel_metrics(las, .stdmetrics, res = 40, pkg = "terra"))
#> utilisateur     système      écoulé 
#>       1.134       0.029       1.119
system.time(pixel_metrics(las, .stdmetrics, res = 40, pkg = "stars"))
#> utilisateur     système      écoulé 
#>       0.195       0.004       0.155

The call stack is incredibly complex for terra