r-spatialecology/landscapemetrics

IIASA 2023 work

Nowosad opened this issue · 7 comments

Improvements (see https://github.com/Nowosad/lsm2023improvements):

  • create an "extras" mechanism for calculate_lsm() (and other related functions) to speed-up calculations of many metrics at the same time (see #154 and #199) [jn: added to the commoncalc branch]
  • test if as.int() gives any speed improvements [no visible improvements or deterioration in terms of speed; however the internal matrix object should be smaller, and thus I would suggest doing it]
  • clean Rcpp code [jn: added some const and &]
  • check if using terra::focalCpp would be beneficial (see #224) [jn: in short, no. It only makes practical sense if the metrics are calculated using a C++ code]
  • try the new_tibble(list( approach [jn: the performance gain is ~20ms; rewritting is probably not worth it] [jn: later, we discovered that actually this was very important to improve window_lsm speed]
  • rcpp_get_coocurrence_matrix_single is used directly and indirectly by ~10 metrics -- there should be a way to improving this part
  • confirm that everything works as expected
  • clean and document the new changes (version 2.1) [jn: see https://github.com/r-spatialecology/landscapemetrics/blob/commoncalcs/NEWS.md#landscapemetrics-210]

Bug fixes:

Questions to answer:

Misc:

  • #260
  • update the FRAGSTATS tests -- #294
  • rerender the book chapter to check 3.1 version
  • create a data base of metrics properties
kadyb commented

test if as.int() gives any speed improvements

The object is R matrix/array or SpatRaster? If SpatRaster, then the object is held in memory as float.

@kadyb yep -- we have a SpatRaster, but then we convert it into a matrix (as.matrix(x, wide = TRUE)). The resulting matrix is either double (when as.int is not used previously) or integer (when as.int is applied beforehand).

I think once your merged the PR with the common calculates, we can also close this issue again?

Yep -- I plan to work on the remaining points during the next week and then I will undraft the PR.

@mhesselbarth My 2.1 changes are ready for your review and merge -- see #308

PR is merged to main and commoncalcs deleted. Will update the CRAN version soon.