Skip to content

Commit 5cb0a47

Browse files
committed
Fix prepare_data
1 parent cf42542 commit 5cb0a47

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

R/mod_plot_prediction.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ plot_prediction <- function(
186186
}
187187
r_habitat <- ecokit::load_as(path_hab, unwrap_r = TRUE) %>%
188188
terra::classify(rcl = cbind(0, NA)) %>%
189-
terra::subset(paste0("SynHab_", hab_abb)) %>%
189+
terra::subset(paste0("synhab_", hab_abb)) %>%
190190
terra::wrap()
191191

192192
invisible(gc())

R/mod_predict_maps.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ predict_maps <- function(
413413
}
414414

415415
r_hab <- ecokit::load_as(r_hab, unwrap_r = TRUE) %>%
416-
magrittr::extract2(paste0("SynHab_", hab_abb))
416+
magrittr::extract2(paste0("synhab_", hab_abb))
417417

418418
# Models are trained and predictions are made only at grid cells with > 0 %
419419
# coverage. Mask layer to exclude grid cells with zero % coverage from

R/mod_prepare_data.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ mod_prepare_data <- function(
6161
"path_roads", "DP_R_roads_processed", TRUE, FALSE,
6262
"path_railway", "DP_R_railway_processed", TRUE, FALSE,
6363
"path_efforts", "DP_R_efforts_processed", TRUE, FALSE,
64-
"path_river", "DP_R_river_processed", FALSE, TRUE,
64+
"path_river", "DP_R_rivers_processed", FALSE, TRUE,
6565
"path_wetness", "DP_R_wetness_processed", FALSE, TRUE,
6666
"path_soil", "DP_R_soil_density", FALSE, TRUE,
6767
"path_model", "DP_R_model_root_path", TRUE, FALSE,
@@ -119,14 +119,14 @@ mod_prepare_data <- function(
119119

120120
if (hab_abb == "0") {
121121
# Use dummy habitat values
122-
r_habitat <- stats::setNames(grid_r, "Hab")
122+
r_habitat <- stats::setNames(grid_r, "hab")
123123
r_habitat_log <- stats::setNames(grid_r, "habitat_log")
124124
} else {
125125
# Load habitat coverage data and mask by the efforts mask
126126
r_habitat <- ecokit::load_as(path_habitat, unwrap_r = TRUE) %>%
127-
magrittr::extract2(paste0("SynHab_", hab_abb)) %>%
127+
magrittr::extract2(paste0("synhab_", hab_abb)) %>%
128128
terra::mask(efforts_mask) %>%
129-
stats::setNames("Hab")
129+
stats::setNames("hab")
130130

131131
# Exclude grid cells with zero habitat coverage
132132
if (exclude_0_habitat) {
@@ -488,7 +488,7 @@ mod_prepare_data <- function(
488488
dplyr::select(tidyselect::all_of(columns_first), tidyselect::everything())
489489

490490
if (hab_abb == "0") {
491-
data_all$Hab <- NA_real_
491+
data_all$hab <- NA_real_
492492
}
493493

494494
# # ..................................................................... ###

R/mod_ssdm_helpers.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,12 @@ extract_sdm_info <- function(model = NULL, cv_fold = NULL) {
381381
#' [mod_prepare_hpc()] and [mod_prepare_data()] functions.
382382
#' @param cv_type Character. Cross-validation type. One of `cv_dist` (default)
383383
#' or `cv_large`. See [mod_cv_fit()] for more details.
384-
#' @param selected_species Character vector or NULL. Names of species to include
385-
#' in modelling; must match names in model data. Default is `NULL` (all
386-
#' species).
387-
#' @param excluded_species Character vector or NULL. Names of species to exclude
388-
#' from modelling; must match names in model data. Default is `NULL` (none
389-
#' excluded).
384+
#' @param selected_species Character vector or `NULL`. Names of species to
385+
#' include in modelling; must match names in model data. Default is `NULL`
386+
#' (all species).
387+
#' @param excluded_species Character vector or `NULL`. Names of species to
388+
#' exclude from modelling; must match names in model data. Default is `NULL`
389+
#' (none excluded).
390390
#' @param env_file Character. Path to a file with environment variable
391391
#' definitions for spatial datasets. Default is `".env"`.
392392
#' @param hab_abb Character. Abbreviation for a single SynHab habitat type.
@@ -1044,7 +1044,7 @@ prepare_input_data <- function(
10441044
}
10451045

10461046
r_hab <- ecokit::load_as(r_hab, unwrap_r = TRUE) %>%
1047-
magrittr::extract2(paste0("SynHab_", hab_abb))
1047+
magrittr::extract2(paste0("synhab_", hab_abb))
10481048

10491049
# Models are trained and predictions are made only at grid cells with > 0 %
10501050
# coverage. Mask layer to exclude grid cells with zero % coverage from

0 commit comments

Comments
 (0)