Skip to content

Commit 5f9add3

Browse files
committed
Fix chelsa and clc
1 parent c1741ab commit 5f9add3

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Package: IASDT.R
33
Title: Modelling the distribution of invasive alien plant species in
44
Europe
55
Version: 0.1.09
6-
Date: 2025-09-18
6+
Date: 2025-09-19
77
Authors@R:
88
person("Ahmed", "El-Gabbas", , "ahmed.el-gabbas@ufz.de", role = c("aut", "cre"),
99
comment = c(ORCID = "0000-0003-2225-088X"))

R/dwf_chelsa_prepare.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ chelsa_prepare <- function(
3333

3434
# Avoid "no visible binding for global variable" message
3535
# https://www.r-bloggers.com/2019/08/no-visible-binding-for-global-variable/
36-
variable <- path_down <- time_period <- extension <- climate_scenario <-
36+
variable <- path_download <- time_period <- extension <- climate_scenario <-
3737
path_chelsa_in <- path_file <- path_out_tif <- path_out_netcdf <-
3838
path_chelsa_out <- path_dwnload_links <- url <- path_dir <- url_file <-
3939
climate_model <- exclude <- chelsa_base_url <- NULL
@@ -158,7 +158,7 @@ chelsa_prepare <- function(
158158
dplyr::filter(stringr::str_detect(variable, selected_vars)) %>%
159159
dplyr::mutate(
160160

161-
path_down = purrr::map_chr(
161+
path_download = purrr::map_chr(
162162
.x = path_file, .f = ~ fs::path(path_chelsa_in, .x)),
163163

164164
path_out_tif = purrr::map_chr(
@@ -172,7 +172,7 @@ chelsa_prepare <- function(
172172
.x = path_out_netcdf, .f = stringr::str_replace_all,
173173
pattern = ".tif$", replacement = ".nc"),
174174
down_command = purrr::map2_chr(
175-
.x = url, .y = path_down,
175+
.x = url, .y = path_download,
176176
.f = ~ stringr::str_glue(
177177
'curl -k -L --connect-timeout 240 --max-time 1200 --retry 5 \\
178178
"{.x}" -o "{.y}" --silent')),
@@ -219,7 +219,7 @@ chelsa_prepare <- function(
219219
data_to_down <- chelsa_metadata %>%
220220
dplyr::mutate(
221221
exclude = furrr::future_map_lgl(
222-
.x = path_down,
222+
.x = path_download,
223223
.f = ~ {
224224

225225
if (file.exists(.x)) {
@@ -259,7 +259,7 @@ chelsa_prepare <- function(
259259
X = seq_len(nrow(data_to_down)),
260260
FUN = function(x) {
261261

262-
path_out <- data_to_down$path_down[x]
262+
path_out <- data_to_down$path_download[x]
263263
try_n <- 0
264264

265265
repeat {

R/dwf_chelsa_project.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ chelsa_project <- function(
3737
# Check metadata columns
3838
needed_columns <- c(
3939
"scale", "offset", "path_out_tif", "climate_model", "climate_scenario",
40-
"variable", "url", "path_down", "long_name", "explanation",
40+
"variable", "url", "path_download", "long_name", "explanation",
4141
"path_out_netcdf", "unit", "time_period")
4242
missing_columns <- setdiff(needed_columns, names(metadata))
4343
if (length(missing_columns) > 0) {
@@ -54,9 +54,9 @@ chelsa_project <- function(
5454

5555
# # ..................................................................... ###
5656

57-
if (!file.exists(metadata$path_down)) {
57+
if (!file.exists(metadata$path_download)) {
5858
ecokit::stop_ctx(
59-
"Input file does not exist", path = metadata$path_down,
59+
"Input file does not exist", path = metadata$path_download,
6060
include_backtrace = TRUE)
6161
}
6262

@@ -126,8 +126,8 @@ chelsa_project <- function(
126126
# later consider the scale and offset information manually. This is more safe
127127
# as I found that some of the future projections do not include such
128128
# information in the tiff files.
129-
r_map <- terra::rast(metadata$path_down, raw = TRUE) %>%
130-
stats::setNames(basename(metadata$path_down)) %>%
129+
r_map <- terra::rast(metadata$path_download, raw = TRUE) %>%
130+
stats::setNames(basename(metadata$path_download)) %>%
131131
# crop to European boundaries although it is not necessary to crop the input
132132
# maps into the European boundaries, we will crop the data prior to
133133
# projection. Cropping will make the values of the raster read from memory
@@ -191,7 +191,7 @@ chelsa_project <- function(
191191
# global attributes to be added to the *.nc file
192192
attributes <- c(
193193
paste0("url=", metadata$url),
194-
paste0("original_file=", metadata$path_down),
194+
paste0("original_file=", metadata$path_download),
195195
paste0("variable=", metadata$variable),
196196
paste0("time_period=", metadata$time_period),
197197
paste0("climate_model=", metadata$climate_model),

R/dwf_clc_process.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,8 @@ clc_process <- function(
590590
future::plan("sequential", gc = TRUE)
591591
} else {
592592
ecokit::set_parallel(
593-
n_cores = n_cores_plot, level = 1L, strategy = strategy)
593+
n_cores = n_cores_plot, level = 1L, strategy = strategy,
594+
future_max_size = 1000L)
594595
withr::defer(future::plan("sequential", gc = TRUE))
595596
}
596597

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@ If you use the `IASDT.R` package, please cite it as:
8181
> <a href="https://biodt.eu" target="_blank">https://biodt.eu</a>.
8282
8383
<span style=" color: grey !important;">Last update:
84-
2025-09-18</span>
84+
2025-09-19</span>

0 commit comments

Comments
 (0)