## ############################################################################
##
## The 2024 Lancet Countdown in Europe report
## Indicator 1.3.6: Climatic Suitability for Ticks
##
## Script 04: Collect environmental suitability weights
## 
## Authors: 
## - Martín Lotto Batista, ORCID: 0000-0002-9437-5270
## - Prof. Rachel Lowe, ORCID: 0000-0003-3939-7343
##
## Contact: martin.lotto@bsc.es
## 
## ############################################################################

# Packages
pacman::p_load(tidyverse, sf, raster)

# Maps
fls <- list.files("data/data_in/land_use/out", full.names=T)
tifs <- lapply(fls, raster)

# Merge tifs of the map
all <- tifs[[1]]
for(i in 2:length(tifs)){
  all <- merge(all, tifs[[i]]) 
  cat("\r", i)
}

all <- projectRaster(all, crs="+init=EPSG:3035")

# Save raster
writeRaster(all, "data/data_in/land_use/weigths.grd", 
            format="raster",     
            options=c("INTERLEAVE=BAND","COMPRESS=LZW"),
            overwrite=TRUE)

## END