Skip to content

Commit 8bcdd70

Browse files
committed
use ragg::agg_jpeg instead of grDevices::jpeg
1 parent d58f6b1 commit 8bcdd70

12 files changed

+55
-56
lines changed

R/DWF_CLC_plot.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ CLC_plot <- function(
211211

212212
# Using ggplot2::ggsave directly does not show non-ascii characters
213213
# correctly
214-
grDevices::jpeg(
215-
filename = TilePath, width = 25, height = 23, units = "cm",
216-
quality = 100, res = 600)
214+
ragg::agg_jpeg(
215+
filename = TilePath, width = 25, height = 23, res = 600,
216+
quality = 100, units = "cm")
217217
print(Plot)
218218
grDevices::dev.off()
219219

@@ -245,9 +245,9 @@ CLC_plot <- function(
245245

246246
# Using ggplot2::ggsave directly does not show non-ascii characters
247247
# correctly
248-
grDevices::jpeg(
249-
filename = TilePathFree, width = 25, height = 23, units = "cm",
250-
quality = 100, res = 600)
248+
ragg::agg_jpeg(
249+
filename = TilePathFree, width = 25, height = 23, res = 600,
250+
quality = 100, units = "cm")
251251
print(Plot)
252252
grDevices::dev.off()
253253

@@ -300,9 +300,9 @@ CLC_plot <- function(
300300

301301
# Using ggplot2::ggsave directly does not show non-ascii characters
302302
# correctly
303-
grDevices::jpeg(
304-
filename = out_path[.x], width = 28, height = 15, units = "cm",
305-
quality = 100, res = 600)
303+
ragg::agg_jpeg(
304+
filename = out_path[.x], width = 28, height = 15, res = 600,
305+
quality = 100, units = "cm")
306306
print(Plot)
307307
grDevices::dev.off()
308308

R/DWF_EASIN_plot.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ EASIN_plot <- function(env_file = ".env") {
184184
margin = ggplot2::margin(0, 0, 0, 0))))
185185

186186
# Using ggplot2::ggsave directly does not show non-ascii characters correctly
187-
grDevices::jpeg(
187+
ragg::agg_jpeg(
188188
filename = IASDT.R::path(Path_EASIN_Summary, "EASIN_Data.jpeg"),
189-
width = 20, height = 10.3, units = "cm", quality = 100, res = 600)
189+
width = 20, height = 10.3, res = 600, quality = 100, units = "cm")
190190
print(Plot)
191191
grDevices::dev.off()
192192

@@ -267,10 +267,10 @@ EASIN_plot <- function(env_file = ".env") {
267267

268268
# Using ggplot2::ggsave directly does not show non-ascii characters
269269
# correctly
270-
grDevices::jpeg(
270+
ragg::agg_jpeg(
271271
filename = IASDT.R::path(
272272
Path_EASIN_Summary, paste0(File_prefix, "_p", i, ".jpeg")),
273-
width = 30, height = 16.5, units = "cm", quality = 100, res = 600)
273+
width = 30, height = 16.5, res = 600, quality = 100, units = "cm")
274274
print(Plot)
275275
grDevices::dev.off()
276276

R/DWF_GBIF_process.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,9 @@ GBIF_process <- function(
533533
cowplot::plot_grid(MainTitle, ., ncol = 1, rel_heights = c(0.035, 1))
534534

535535
# Using ggplot2::ggsave directly does not show non-ascii characters correctly
536-
grDevices::jpeg(
536+
ragg::agg_jpeg(
537537
filename = IASDT.R::path(Path_GBIF, "GBIF_Summary.jpeg"),
538-
width = 25, height = 25.8, units = "cm", quality = 100, res = 600)
538+
width = 25, height = 25.8, res = 600, quality = 100, units = "cm")
539539
print(Plot)
540540
grDevices::dev.off()
541541

R/DWF_GBIF_species_data.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ GBIF_species_data <- function(
206206

207207
# Using ggplot2::ggsave directly does not show non-ascii characters
208208
# correctly
209-
grDevices::jpeg(
210-
filename = FilePath_Plot,
211-
width = 25, height = 25, units = "cm", quality = 100, res = 600)
209+
ragg::agg_jpeg(
210+
filename = FilePath_Plot, width = 25, height = 25, res = 600,
211+
quality = 100, units = "cm")
212212
print(SpPlot)
213213
grDevices::dev.off()
214214

R/DWF_IAS_distribution.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,15 @@ IAS_distribution <- function(
244244

245245
IASDT.R::cat_time(
246246
paste0("There are ", length(Countries2Exclude), " countries to exclude:"),
247-
level = 2)
247+
level = 2, time = FALSE)
248248

249249
# Mask grid to exclude countries - `TRUE` for grid cells to be considered as
250250
# presence if present in any of the data source; `FALSE` for grid cells need
251251
# to be masked as 0 in species distribution maps (1 becomes 0)
252252
if (length(Countries2Exclude) > 0) {
253253

254254
IASDT.R::cat_time(
255-
paste(sort(Countries2Exclude), collapse = " + "), level = 3)
255+
paste(sort(Countries2Exclude), collapse = " + "), level = 3, time = FALSE)
256256

257257
Mask_Keep <- Grid_10_CNT %>%
258258
dplyr::mutate(Keep = !(Country %in% Countries2Exclude)) %>%
@@ -621,7 +621,7 @@ IAS_distribution <- function(
621621

622622
iNatur_DT <- IASDT.R::path(Path_GBIF, "iNaturalist_Count.RData") %>%
623623
IASDT.R::load_as() %>%
624-
dplyr::filter(species == species)
624+
dplyr::filter(species == !!species)
625625

626626
if (nrow(iNatur_DT) > 0) {
627627
iNatur_Unique <- iNatur_DT$iNaturalist_Unique

R/DWF_IAS_plot.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,9 @@ IAS_plot <- function(species = NULL, env_file = ".env", overwrite = FALSE) {
286286
#
287287
# Using ggplot2::ggsave directly does not show non-ascii characters correctly
288288

289-
grDevices::jpeg(
290-
filename = out_path, width = 25, height = 26.5, units = "cm",
291-
quality = 100, res = 600)
292-
289+
ragg::agg_jpeg(
290+
filename = out_path, width = 25, height = 26.5,
291+
res = 600, quality = 100, units = "cm")
293292
print(Plot)
294293
grid::grid.text(
295294
label = LastUpdate, x = 0.98, y = 0.975, hjust = 1, vjust = 1,

R/DWF_IAS_process.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ IAS_process <- function(env_file = ".env", n_cores = 6L, overwrite = TRUE) {
168168

169169
## Prepare working on parallel -----
170170
IASDT.R::cat_time(
171-
paste0("Prepare working on parallel using ", n_cores, " cores."),
171+
paste0("Prepare working on parallel using ", n_cores, " cores"),
172172
level = 1)
173173

174174
if (n_cores == 1) {
@@ -429,9 +429,9 @@ IAS_process <- function(env_file = ".env", n_cores = 6L, overwrite = TRUE) {
429429

430430
# Using ggplot2::ggsave directly does not show non-ascii characters
431431
# correctly
432-
grDevices::jpeg(
432+
ragg::agg_jpeg(
433433
filename = IASDT.R::path(Path_PA, "IAS_NumSpecies.jpeg"),
434-
width = 30, height = 15.5, units = "cm", quality = 100, res = 600)
434+
width = 30, height = 15.5, res = 600, quality = 100, units = "cm")
435435
print(Plot)
436436
grDevices::dev.off()
437437

@@ -489,9 +489,9 @@ IAS_process <- function(env_file = ".env", n_cores = 6L, overwrite = TRUE) {
489489
size = 7, hjust = 1)
490490

491491
# Using ggplot2::ggsave directly does not show non-ascii characters correctly
492-
grDevices::jpeg(
492+
ragg::agg_jpeg(
493493
filename = IASDT.R::path(Path_PA, "IAS_NumSpecies_Masked.jpeg"),
494-
width = 30, height = 15.5, units = "cm", quality = 100, res = 600)
494+
width = 30, height = 15.5, res = 600, quality = 100, units = "cm")
495495
print(Plot)
496496
grDevices::dev.off()
497497

@@ -662,9 +662,9 @@ IAS_process <- function(env_file = ".env", n_cores = 6L, overwrite = TRUE) {
662662
ncol = 1, rel_heights = c(0.05, 1, 0.05))
663663

664664
# Using ggplot2::ggsave directly does not show non-ascii characters correctly
665-
grDevices::jpeg(
665+
ragg::agg_jpeg(
666666
filename = IASDT.R::path(Path_PA, "IAS_NSp_threshold_Hab.jpeg"),
667-
width = 30, height = 17, units = "cm", quality = 100, res = 600)
667+
width = 30, height = 17, res = 600, quality = 100, units = "cm")
668668
print(Plot)
669669
grDevices::dev.off()
670670

R/DWF_efforts_plot.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ efforts_plot <- function(env_file = ".env") {
168168

169169
# Using ggplot2::ggsave directly does not show non-ascii characters
170170
# correctly
171-
grDevices::jpeg(
171+
ragg::agg_jpeg(
172172
filename = IASDT.R::path(Path_Efforts, PlotDF$FileName[[.x]]),
173-
width = 31, height = 16.25, units = "cm", quality = 100, res = 600)
173+
width = 31, height = 16.25, res = 600, quality = 100, units = "cm")
174174
print(CurrPlot)
175175
grDevices::dev.off()
176176

R/DWF_railway_intensity.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,9 @@ railway_intensity <- function(
574574

575575
# Using ggplot2::ggsave directly does not show non-ascii characters
576576
# correctly
577-
grDevices::jpeg(
577+
ragg::agg_jpeg(
578578
filename = IASDT.R::path(Path_Railways, "Railways_Length.jpeg"),
579-
width = 31, height = 30, units = "cm", quality = 100, res = 600)
579+
width = 31, height = 30, res = 600, quality = 100, units = "cm")
580580
print(RailPlot)
581581
grDevices::dev.off()
582582

@@ -605,9 +605,9 @@ railway_intensity <- function(
605605

606606
# Using ggplot2::ggsave directly does not show non-ascii characters
607607
# correctly
608-
grDevices::jpeg(
608+
ragg::agg_jpeg(
609609
filename = IASDT.R::path(Path_Railways, "Railways_Lines.jpeg"),
610-
width = 31, height = 30, units = "cm", quality = 100, res = 600)
610+
width = 31, height = 30, res = 600, quality = 100, units = "cm")
611611
print(RailPlotShp)
612612
grDevices::dev.off()
613613

R/DWF_road_intensity.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@ road_intensity <- function(env_file = ".env") {
388388
margin = ggplot2::margin(0, 0, 0.5, 0))))
389389

390390
# Using ggplot2::ggsave directly does not show non-ascii characters correctly
391-
grDevices::jpeg(
391+
ragg::agg_jpeg(
392392
filename = IASDT.R::path(Path_Roads, "Road_Length.jpeg"),
393-
width = 30, height = 21, units = "cm", quality = 100, res = 600)
393+
width = 30, height = 21, res = 600, quality = 100, units = "cm")
394394
print(Plots_Length)
395395
grDevices::dev.off()
396396

@@ -435,9 +435,9 @@ road_intensity <- function(env_file = ".env") {
435435
margin = ggplot2::margin(0, 0, 1, 0))))
436436

437437
# Using ggplot2::ggsave directly does not show non-ascii characters correctly
438-
grDevices::jpeg(
438+
ragg::agg_jpeg(
439439
filename = IASDT.R::path(Path_Roads, "Road_Distance.jpeg"),
440-
width = 30, height = 21, units = "cm", quality = 100, res = 600)
440+
width = 30, height = 21, res = 600, quality = 100, units = "cm")
441441
print(Plots_Distance)
442442
grDevices::dev.off()
443443

R/mod_prepare_HPC.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,10 @@ mod_prepare_HPC <- function(
569569

570570
# Using ggplot2::ggsave directly does not show non-ascii characters
571571
# correctly
572-
grDevices::jpeg(
572+
ragg::agg_jpeg(
573573
filename = IASDT.R::path(path_model, "NSpPerGrid_Sub.jpeg"),
574-
width = 25, height = plot_height, units = "cm", quality = 100, res = 600)
574+
width = 25, height = plot_height, res = 600, quality = 100, units = "cm")
575+
575576
print(NSpPerGrid_Sub)
576577
grDevices::dev.off()
577578

R/mod_variance_partitioning_plot.R

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,9 @@ variance_partitioning_plot <- function(
293293
Theme +
294294
ggplot2::guides(fill = ggplot2::guide_legend(nrow = 1, byrow = TRUE))
295295

296-
grDevices::jpeg(
296+
ragg::agg_jpeg(
297297
filename = IASDT.R::path(Path_VarPar, "VarPar_Relative_ByTaxonomy.jpeg"),
298-
width = width, height = height,
299-
units = "cm", quality = 100, res = 600)
298+
width = width, height = height, res = 600, quality = 100, units = "cm")
300299
plot(Plot_Relative_Orig)
301300
grDevices::dev.off()
302301

@@ -325,10 +324,9 @@ variance_partitioning_plot <- function(
325324

326325
# Using ggplot2::ggsave directly does not show non-ascii characters
327326
# correctly
328-
grDevices::jpeg(
327+
ragg::agg_jpeg(
329328
filename = IASDT.R::path(Path_VarPar, "VarPar_Relative_ByTjurR2.jpeg"),
330-
width = width, height = height,
331-
units = "cm", quality = 100, res = 600)
329+
width = width, height = height, res = 600, quality = 100, units = "cm")
332330
plot(Plot_Relative_TjurR2)
333331
grDevices::dev.off()
334332

@@ -460,9 +458,10 @@ variance_partitioning_plot <- function(
460458

461459
# Using ggplot2::ggsave directly does not show non-ascii characters
462460
# correctly
463-
grDevices::jpeg(
461+
ragg::agg_jpeg(
464462
filename = IASDT.R::path(Path_VarPar, "VarPar_Raw_ByTaxonomy.jpeg"),
465-
width = width, height = height, units = "cm", quality = 100, res = 600)
463+
width = width, height = height, res = 600, quality = 100, units = "cm")
464+
466465
plot(Plot_Raw)
467466
grDevices::dev.off()
468467

@@ -492,9 +491,9 @@ variance_partitioning_plot <- function(
492491

493492
# Using ggplot2::ggsave directly does not show non-ascii characters
494493
# correctly
495-
grDevices::jpeg(
494+
ragg::agg_jpeg(
496495
filename = IASDT.R::path(Path_VarPar, "VarPar_Raw_ByMean.jpeg"),
497-
width = width, height = height, units = "cm", quality = 100, res = 600)
496+
width = width, height = height, res = 600, quality = 100, units = "cm")
498497
plot(Plot_Raw_TotalRaw)
499498
grDevices::dev.off()
500499

@@ -524,9 +523,9 @@ variance_partitioning_plot <- function(
524523

525524
# Using ggplot2::ggsave directly does not show non-ascii characters
526525
# correctly
527-
grDevices::jpeg(
526+
ragg::agg_jpeg(
528527
filename = IASDT.R::path(Path_VarPar, "VarPar_Raw_ByTotalNonSpatial.jpeg"),
529-
width = width, height = height, units = "cm", quality = 100, res = 600)
528+
width = width, height = height, res = 600, quality = 100, units = "cm")
530529
plot(Plot_Raw_NonSpatial)
531530
grDevices::dev.off()
532531

0 commit comments

Comments
 (0)