Closed DanWismer closed 1 year ago
Nice idea @DanWismer. Unless you've already got the code, I can take this one to improve my matrix skills. Maybe I'll create a PR so you can review it?
Thanks Marc, that would be great if you could tackle this!
You can give this a try:
library(terra)
library(prioritizr)
# wtw planning units
pu <- rast(PU.tif)
# list of tiffs
tiffs <- list.files("Tiffs", pattern = ".tif$", full.names = TRUE)
# sparse matrix
rij <- rij_matrix(pu, rast(tiffs))
# save as rds
saveRDS(rij, "rij.rds", compress = TRUE)
Instead of one .rds
maybe it would be good to split it up into a couple. For example by grouped theme, weights and includes/excludes. We can save the output(s) in another folder called RIJ?
With those sparse matrix built and saved, it will make it easier to do post WTW analysis.
We could do something like this to parse out the lists of rasters in the Tiffs folder:
# list of ECCC SAR tifs
tiffs <- list.files(tiffs_path, pattern = "^T_ECCC_SAR.*\\.tif$", full.names = TRUE)
An optional script that creates rij matrix of the layers in the Tiffs folder and saves them as
.rds
file. This will be handy for aResilience Index
work flow that can quickly summarize layers that intersect a WTW site selection output.