Skip to content

Commit f427873

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

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

R/dwf_chelsa_process.R

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ chelsa_process <- function(
310310

311311
tiffs_okay <- all(
312312
ecokit::check_tiff(file_tif, warning = FALSE),
313-
ecokit::check_tiff(file_nc, warning = FALSE)) %>%
314-
suppressWarnings()
313+
ecokit::check_tiff(file_nc, warning = FALSE))
315314

316315
if (tiffs_okay) {
317316
return(FALSE)
@@ -330,14 +329,21 @@ chelsa_process <- function(
330329
attempt <- attempt + 1
331330
try_n <- try(
332331
expr = {
333-
IASDT.R::chelsa_project(
334-
metadata = dplyr::slice(chelsa_to_process, x),
335-
env_file = env_file, compression_level = compression_level) %>%
336-
# suppress known warning
337-
# https://github.com/rspatial/terra/issues/1212
338-
# https://github.com/rspatial/terra/issues/1832
339-
# https://stackoverflow.com/questions/78098166
340-
suppressWarnings()
332+
# suppress known warning
333+
# https://github.com/rspatial/terra/issues/1212
334+
# https://github.com/rspatial/terra/issues/1832
335+
# https://stackoverflow.com/questions/78098166
336+
337+
ecokit::quietly(
338+
expr = {
339+
IASDT.R::chelsa_project(
340+
metadata = dplyr::slice(chelsa_to_process, x),
341+
env_file = env_file, compression_level = compression_level)
342+
},
343+
"is not a Time or Vertical dimension",
344+
"driver GTiff does not support open option so",
345+
"is not a Longitude/X dimension")
346+
341347
"Okay"
342348
},
343349
silent = TRUE)
@@ -346,16 +352,14 @@ chelsa_process <- function(
346352

347353
tiffs_okay <- all(
348354
ecokit::check_tiff(file_tif, warning = FALSE),
349-
ecokit::check_tiff(file_nc, warning = FALSE)) %>%
350-
suppressWarnings()
355+
ecokit::check_tiff(file_nc, warning = FALSE))
351356

352-
if ((!inherits(try_n, "try-error") && tiffs_okay) || attempt >= 5) {
357+
if ((!inherits(try_n, "try-error") && tiffs_okay) || attempt >= 10) {
353358
break
354359
}
355360

356361
if (inherits(try_n, "try-error") &&
357-
isFALSE(
358-
ecokit::check_tiff(path_download, warning = FALSE))) {
362+
isFALSE(ecokit::check_tiff(path_download, warning = FALSE))) {
359363
# re-download the file if it fails to be processed and downloaded
360364
# file is not valid
361365
system(
@@ -390,7 +394,7 @@ chelsa_process <- function(
390394
ecokit::stop_ctx(
391395
paste0(
392396
"\n >> ", nrow(chelsa_to_process), " files failed to process.\n",
393-
" >> Check `FailedProcessing.txt` for more details"),
397+
" >> Check `failed_processing.txt` for more details"),
394398
chelsa_to_process = chelsa_to_process, include_backtrace = TRUE)
395399
}
396400

R/dwf_clc_plot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ clc_plot <- function(clc_name, clc_map, eu_map, crosswalk, path_jpeg) {
342342

343343
rm(
344344
maps, path_jpeg_2_free, plot_theme, plot_theme_2, prefix,
345-
out_path, x_lim, y_lim, last_update, env = environment())
345+
out_path, x_lim, y_lim, last_update, envir = environment())
346346

347347
# Multiple panels per file
348348
common_legend <- cowplot::get_legend(

0 commit comments

Comments
 (0)