Skip to content

Commit 3accbfc

Browse files
committed
Fix chelsa and clc
1 parent 56651fb commit 3accbfc

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

R/dwf_chelsa_process.R

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,8 @@ chelsa_process <- function(
264264
return(TRUE)
265265
}
266266

267-
netcdf_okay <- suppressWarnings(
268-
ecokit::check_tiff(file_nc, warning = FALSE))
269-
tif_okay <- suppressWarnings(
270-
ecokit::check_tiff(file_tif, warning = FALSE))
267+
netcdf_okay <- ecokit::check_tiff(file_nc, warning = FALSE)
268+
tif_okay <- ecokit::check_tiff(file_tif, warning = FALSE)
271269
need_processing <- isFALSE(netcdf_okay && tif_okay)
272270

273271
if (need_processing) {
@@ -316,9 +314,6 @@ chelsa_process <- function(
316314
return(FALSE)
317315
}
318316

319-
if (file.exists(file_nc)) fs::file_delete(file_nc)
320-
if (file.exists(file_tif)) fs::file_delete(file_tif)
321-
322317
# Set `GTIFF_SRS_SOURCE` configuration option to EPSG to use
323318
# official parameters (overriding the ones from GeoTIFF keys)
324319
# see: https://stackoverflow.com/questions/78007307
@@ -363,8 +358,6 @@ chelsa_process <- function(
363358
command = chelsa_to_process$download_command[[x]],
364359
ignore.stdout = TRUE, ignore.stderr = TRUE)
365360
}
366-
if (file.exists(file_nc)) fs::file_delete(file_nc)
367-
if (file.exists(file_tif)) fs::file_delete(file_tif)
368361
}
369362

370363
if (inherits(try_n, "try-error")) {

R/dwf_chelsa_project.R

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ chelsa_project <- function(
114114
"extdata", "LandMask.nc", package = "IASDT.R", mustWork = TRUE) %>%
115115
terra::rast() %>%
116116
terra::crop(crop_extent) %>%
117-
suppressWarnings() %>% # suppress warning on LUMI while cropping
118117
terra::classify(cbind(0, NA))
119118

120119
# # ..................................................................... ###
@@ -201,12 +200,17 @@ chelsa_project <- function(
201200
paste0("explanation=", metadata$explanation))
202201

203202
# save as *.nc file
204-
terra::writeCDF(
205-
r_map,
206-
filename = metadata$path_out_netcdf, varname = var_name_for_nc,
207-
unit = metadata$unit, zname = metadata$time_period,
208-
atts = attributes, overwrite = TRUE, compression = compression_level)
209203

204+
ecokit::quietly({
205+
terra::writeCDF(
206+
r_map,
207+
filename = metadata$path_out_netcdf, varname = var_name_for_nc,
208+
unit = metadata$unit, zname = metadata$time_period,
209+
atts = attributes, overwrite = TRUE, compression = compression_level)
210+
211+
},
212+
"is not a Latitude/Y dimension.",
213+
"is not a Longitude/X dimension.")
210214
# # ..................................................................... ###
211215

212216
return(invisible(NULL))

R/dwf_clc_plot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ clc_plot <- function(clc_name, clc_map, eu_map, crosswalk, path_jpeg) {
404404
grDevices::dev.off()
405405
})
406406

407-
rm(maps, common_legend, prefix, out_path, last_update, env = environment())
407+
rm(maps, common_legend, prefix, out_path, last_update, envir = environment())
408408

409409
invisible(NULL)
410410
}

0 commit comments

Comments
 (0)