2023-10-08
# online
# remotes::install_github("r-spatialecology/landscapemetrics@basemetrics3")
# remotes::install_github("r-spatialecology/landscapemetrics@commoncalcs")
# or locally
devtools::load_all("~/Software/landscapemetrics3")
## ℹ Loading landscapemetrics3
## Starting from v2.0.0, landscapemetrics does not support the 'raster' or 'sp' packages.
## They are replaced by 'terra' and 'sf', respectively. More information
## about the 'terra' package can be found here: https://rspatial.org/index.html.
devtools::load_all("~/Software/landscapemetrics")
## ℹ Loading landscapemetrics
landscape <- terra::rast(landscapemetrics::augusta_nlcd)
# landscape <- terra::disagg(landscape, 4)
# landscape <- terra::aggregate(landscape, 4, fun = "modal")
bench::mark(landscapemetrics::calculate_lsm(landscape, verbose = FALSE),
landscapemetrics3::calculate_lsm(landscape, verbose = FALSE),
iterations = 1, check = FALSE)
## Warning: Some expressions had a GC in every iteration; so filtering is
## disabled.
## # A tibble: 2 × 6
## expression min median `itr/sec` mem_alloc `gc/sec`
## <bch:expr> <bch:> <bch:> <dbl> <bch:byt> <dbl>
## 1 landscapemetrics::calculate_lsm(la… 3.06m 3.06m 0.00544 17GB 0.468
## 2 landscapemetrics3::calculate_lsm(l… 17.7m 17.7m 0.000941 54.4GB 0.215
landscape2 <- terra::rast(landscapemetrics::landscape)
# landscape <- terra::disagg(landscape, 4)
# landscape <- terra::aggregate(landscape, 4, fun = "modal")
bench::mark(landscapemetrics::calculate_lsm(landscape2, verbose = FALSE),
landscapemetrics3::calculate_lsm(landscape2, verbose = FALSE),
iterations = 10, check = FALSE)
## # A tibble: 2 × 6
## expression min median `itr/sec` mem_alloc `gc/sec`
## <bch:expr> <bch:t> <bch:tm> <dbl> <bch:byt> <dbl>
## 1 landscapemetrics::calculate_lsm… 523.3ms 618.96ms 1.47 17.5MB 0.980
## 2 landscapemetrics3::calculate_ls… 6.8s 7.36s 0.127 45.6MB 0