diff --git a/R/produire_carte_statique.R b/R/produire_carte_statique.R index 7c1ee3a..c746c84 100644 --- a/R/produire_carte_statique.R +++ b/R/produire_carte_statique.R @@ -43,6 +43,7 @@ produire_carte_statique <- function(onde_df_mois = NULL, referentiel_onde = 'Typologie nationale', couleurs = onde_4mod, dptFR_shp = NULL) { + if (is.null(code_departement)) { stop("code dpt manquant") } @@ -75,6 +76,12 @@ produire_carte_statique <- function(onde_df_mois = NULL, } }) + # ajout des pays frontaliers pour gerer les departements avec de la terre + pays_front <- sf::read_sf(dsn = "https://gisco-services.ec.europa.eu/distribution/v2/countries/geojson/CNTR_RG_01M_2024_4326.geojson") %>% + dplyr::filter(NAME_FREN %in% c("Italie", "Suisse", "Luxembourg", "Espagne", "Belgique", "Allemagne", "Andorre", "France")) %>% + sf::st_transform(crs = 2154) + + onde_df_mois <- onde_df_mois %>% dplyr::filter(code_departement == { @@ -116,6 +123,7 @@ produire_carte_statique <- function(onde_df_mois = NULL, } ggplot2::ggplot() + + ggplot2::geom_sf(data = pays_front , fill = "lightgrey") + ggplot2::geom_sf(data = dptFR_shp , fill = "grey95") + ggplot2::geom_sf(data = dpt_shp, fill = "grey70", @@ -161,16 +169,18 @@ produire_carte_statique <- function(onde_df_mois = NULL, ) + ggplot2::ggtitle( label = glue::glue( - 'R\u00e9seau ONDE - {unique(onde_df_mois$libelle_departement)} - Campagne {unique(onde_df_mois$libelle_type_campagne)} {unique(lubridate::month(onde_df_mois$date_campagne,label = T, locale = \"fr_FR\"))} {unique(lubridate::year(onde_df_mois$date_campagne))}' + 'R\u00e9seau ONDE - {unique(onde_df_mois$libelle_departement)} - Campagne {unique(onde_df_mois$libelle_type_campagne)} {unique(lubridate::month(onde_df_mois$date_campagne,label = T))} {unique(lubridate::year(onde_df_mois$date_campagne))}' ), subtitle = glue::glue('{referentiel_onde}') ) + ggplot2::labs(caption = paste("Source: ONDE (OFB)\n \u00a9OFB", format(Sys.time(), '%Y'), "- Date d\'\u00e9dition:", format(Sys.time(), '%d/%m/%Y'))) + ggplot2::theme_void() + ggplot2::theme( + legend.key = ggplot2::element_rect(fill = NA), # retrait fond sur legende legend.text = ggplot2::element_text(size = 10), legend.title = ggplot2::element_text(face = "bold", size = 9), + legend.background = element_rect(colour = NA), plot.title = ggplot2::element_text(face = "bold", size = 10), plot.subtitle = ggplot2::element_text(face = "italic", @@ -179,7 +189,7 @@ produire_carte_statique <- function(onde_df_mois = NULL, axis.title = ggplot2::element_blank(), axis.ticks.x = ggplot2::element_blank(), axis.ticks.y = ggplot2::element_blank(), - panel.background = ggplot2::element_rect(fill = "lightblue", colour = NA), + panel.background = ggplot2::element_rect(fill = "lightblue", colour = NA), # par defaut la mer panel.grid.major = ggplot2::element_line(colour = NA), panel.grid.minor = ggplot2::element_line(colour = NA), legend.position = "right", diff --git a/inst/rmarkdown/templates/rapport_mensuel_onde_dpt/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/rapport_mensuel_onde_dpt/skeleton/skeleton.Rmd index c530dbd..2ec6cb2 100644 --- a/inst/rmarkdown/templates/rapport_mensuel_onde_dpt/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/rapport_mensuel_onde_dpt/skeleton/skeleton.Rmd @@ -330,7 +330,7 @@ plot_historique <- patchwork::plot_annotation(tag_levels = "a",tag_suffix = ')', #title = "Test", caption = paste("Source: réseau ONDE (OFB)\n ©OFB", - format(Sys.time(), '%Y'), "- Date d'édition:",format(Sys.time(), '%d/%m/%Y'))) & + format(Sys.time(), '%Y'), "- Date d'édition:",format(Sys.time(), '%d/%m/%Y'))) + theme(plot.title = element_text(size = 8, face='bold'), plot.tag = element_text(face = 'bold'))