@@ -259,7 +259,6 @@ predict_maps <- function(
259259 # # Species information -----
260260
261261 species_info <- IASDT.R :: get_species_name(env_file = env_file ) %> %
262- janitor :: clean_names() %> %
263262 dplyr :: select(ias_id , taxon_name , species_name , class , order , family )
264263
265264 # # |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| #
@@ -418,7 +417,9 @@ predict_maps <- function(
418417 # Models are trained and predictions are made only at grid cells with > 0 %
419418 # coverage. Mask layer to exclude grid cells with zero % coverage from
420419 # predictions.
421- r_hab_mask <- terra :: classify(r_hab , cbind(0 , NA ), others = 1 )
420+ # r_hab_mask <- terra::classify(r_hab, cbind(0, NA), others = 1)
421+ # Update 2025_09: make predictions at the full study area, and if needed
422+ # predictions at 0% coverage could be masked
422423
423424 r_hab <- stats :: setNames(log10(r_hab + 0.1 ), " habitat_log" )
424425
@@ -759,13 +760,8 @@ predict_maps <- function(
759760 # # Merge static predictors -----
760761 ecokit :: cat_time(" Merge static predictors" , level = 1L )
761762
762- static_predictors <- terra :: rast(static_predictors )
763-
764- # If Habitat predictor is used, grid cells with zero % coverage are
765- # excluded from predictions
766- if (hab_predictor ) {
767- static_predictors <- terra :: mask(static_predictors , r_hab_mask )
768- }
763+ static_predictors <- terra :: rast(static_predictors ) %> %
764+ terra :: mask(ecokit :: load_as(path_grid_r , unwrap_r = TRUE ))
769765
770766 # # ..................................................................... ###
771767 # # ..................................................................... ###
@@ -871,7 +867,7 @@ predict_maps <- function(
871867 do_clamp <- prediction_options $ clamp [[id ]]
872868
873869 # Name of the current option
874- option_name <- prediction_options $ climate_name [[id ]]
870+ option_name <- prediction_options $ name [[id ]]
875871
876872 # Name of the current model
877873 model_name <- paste0(
@@ -929,7 +925,7 @@ predict_maps <- function(
929925 path_prediction_sf <- fs :: path(
930926 path_prediction , paste0(" prediction_" , option_name , " _sf.qs2" ))
931927 path_prediction_r <- fs :: path(
932- path_prediction , paste0(" prediction_" , option_name , " _R .qs2" ))
928+ path_prediction , paste0(" prediction_" , option_name , " _r .qs2" ))
933929 path_prediction_summary <- fs :: path(
934930 path_prediction , paste0(" prediction_" , option_name , " _summary.RData" ))
935931
@@ -1140,7 +1136,7 @@ predict_maps <- function(
11401136 # use relevant folder containing the current predictions. This is
11411137 # determined by `path_prediction`, which is not the same whether
11421138 # clamping is used or not
1143- path = path_prediction , pattern = " prediction_current.*_R .qs2" ,
1139+ path = path_prediction , pattern = " prediction_current.*_r .qs2" ,
11441140 full.names = TRUE ) %> %
11451141 ecokit :: load_as(unwrap_r = TRUE ) %> %
11461142 terra :: subset(mean_names )
@@ -1326,7 +1322,7 @@ predict_maps <- function(
13261322 current_mean <- list.files(
13271323 path = dplyr :: if_else(
13281324 clamp_pred , path_prediction_clamp , path_prediction_no_clamp ),
1329- pattern = " prediction_current.*_R .qs2" , full.names = TRUE )
1325+ pattern = " prediction_current.*_r .qs2" , full.names = TRUE )
13301326
13311327 # --------------------------------------------------------- #
13321328
@@ -1429,7 +1425,7 @@ predict_maps <- function(
14291425 clamp_pred , path_prediction_clamp , path_prediction_no_clamp ),
14301426 paste0(
14311427 " prediction_" , stringr :: str_replace(time_period , " -" , " _" ), " _" ,
1432- climate_scenario , " _ensemble_R .qs2" ))) %> %
1428+ climate_scenario , " _ensemble_r .qs2" ))) %> %
14331429 dplyr :: select(tidyselect :: all_of(vars_to_select )) %> %
14341430 tidyr :: nest(data = - ensemble_file )
14351431
@@ -1525,7 +1521,7 @@ predict_maps <- function(
15251521 climate_scenario , " _ensemble" ),
15261522 file_pred_sf = NA_character_ ,
15271523 file_pred_r = stringr :: str_replace(
1528- file_pred_summary , " _summary.RData" , " _R .qs2" )) %> %
1524+ file_pred_summary , " _summary.RData" , " _r .qs2" )) %> %
15291525 dplyr :: distinct()
15301526 }
15311527 # # ..................................................................... ###
0 commit comments