From f703f710e7a195936400b798d86b3b737290a667 Mon Sep 17 00:00:00 2001 From: OFB-GE Date: Mon, 11 May 2026 15:09:05 +0200 Subject: [PATCH 1/5] Correction erreur Quitting from skeleton.Rmd:288-340 [historique] --- .../rapport_mensuel_onde_dpt/skeleton/skeleton.Rmd | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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..9bba272 100644 --- a/inst/rmarkdown/templates/rapport_mensuel_onde_dpt/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/rapport_mensuel_onde_dpt/skeleton/skeleton.Rmd @@ -1,5 +1,5 @@ --- -title: "Bilan mensuel ONDE \nObservatoire national des étiages \nDépartement `r params$code_departement`" +title: "Bilan zaza mensuel ONDE \nObservatoire national des étiages \nDépartement `r params$code_departement`" author: "OFB, DR `r params$region_dr`" date: "Campagne `r params$type_rapport` de `r params$mois_rapport` \nrapport créé le `r format(Sys.time(), '%d %B %Y')`" output: @@ -137,6 +137,11 @@ onde_bilan_ecoulement_annee_dpt <- force_complementaire = T) ``` +```{r} + +print("zaza") +``` + Actuellement, le **département `r params$code_departement`** est couvert par **`r nb_stations` stations** d'observations. Pour le département, les dernières campagnes : @@ -330,7 +335,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')) From c817a8d69134a3275dace20488c9763fb82c1513 Mon Sep 17 00:00:00 2001 From: OFB-GE Date: Mon, 11 May 2026 16:25:02 +0200 Subject: [PATCH 2/5] Correction de l'erreur : Failed to evaluate glue component {unique(lubridate::month(onde_df_mois$date_campagne,label = T, locale = "fr_FR"))} Caused by error in `factor() --- R/produire_carte_statique.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/produire_carte_statique.R b/R/produire_carte_statique.R index 7c1ee3a..57a25e3 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") } @@ -115,6 +116,8 @@ produire_carte_statique <- function(onde_df_mois = NULL, couleurs = Couleur_4mod) } + browser() + ggplot2::ggplot() + ggplot2::geom_sf(data = dptFR_shp , fill = "grey95") + ggplot2::geom_sf(data = dpt_shp, @@ -161,7 +164,7 @@ 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}') ) + From 778b8579367212645c0850673bde6d82b3811b24 Mon Sep 17 00:00:00 2001 From: OFB-GE Date: Mon, 11 May 2026 20:14:37 +0200 Subject: [PATCH 3/5] ajout pays frontaliers --- R/produire_carte_statique.R | 22 ++++++++++++++++++- .../skeleton/skeleton.Rmd | 7 +----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/R/produire_carte_statique.R b/R/produire_carte_statique.R index 57a25e3..c3ee014 100644 --- a/R/produire_carte_statique.R +++ b/R/produire_carte_statique.R @@ -76,6 +76,12 @@ produire_carte_statique <- function(onde_df_mois = NULL, } }) + + 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 == { @@ -115,10 +121,23 @@ produire_carte_statique <- function(onde_df_mois = NULL, observations = stringr::str_wrap(lib_ecoul4mod, 12), couleurs = Couleur_4mod) } + # browser() + + # if(code_departement %in% c(08)){ + # fond <- ggplot2::ggplot() + + # ggplot2::geom_rect(data = dpt_shp, + # xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, + # fill = "black") + # } else { + # fond <- ggplot2::ggplot() + + # ggplot2::geom_rect(data = dpt_shp, + # xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, + # fill = "lightblue") + # } - browser() 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", @@ -174,6 +193,7 @@ produire_carte_statique <- function(onde_df_mois = NULL, 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", 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 9bba272..2ec6cb2 100644 --- a/inst/rmarkdown/templates/rapport_mensuel_onde_dpt/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/rapport_mensuel_onde_dpt/skeleton/skeleton.Rmd @@ -1,5 +1,5 @@ --- -title: "Bilan zaza mensuel ONDE \nObservatoire national des étiages \nDépartement `r params$code_departement`" +title: "Bilan mensuel ONDE \nObservatoire national des étiages \nDépartement `r params$code_departement`" author: "OFB, DR `r params$region_dr`" date: "Campagne `r params$type_rapport` de `r params$mois_rapport` \nrapport créé le `r format(Sys.time(), '%d %B %Y')`" output: @@ -137,11 +137,6 @@ onde_bilan_ecoulement_annee_dpt <- force_complementaire = T) ``` -```{r} - -print("zaza") -``` - Actuellement, le **département `r params$code_departement`** est couvert par **`r nb_stations` stations** d'observations. Pour le département, les dernières campagnes : From 8d50fc7f742e4e439435d0df2930697cfd60d68f Mon Sep 17 00:00:00 2001 From: OFB-GE Date: Mon, 11 May 2026 20:14:37 +0200 Subject: [PATCH 4/5] ajout pays frontaliers --- R/produire_carte_statique.R | 25 +++++++++++++++++-- .../skeleton/skeleton.Rmd | 7 +----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/R/produire_carte_statique.R b/R/produire_carte_statique.R index 57a25e3..92a02a5 100644 --- a/R/produire_carte_statique.R +++ b/R/produire_carte_statique.R @@ -76,6 +76,12 @@ produire_carte_statique <- function(onde_df_mois = NULL, } }) + + 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 == { @@ -115,11 +121,24 @@ produire_carte_statique <- function(onde_df_mois = NULL, observations = stringr::str_wrap(lib_ecoul4mod, 12), couleurs = Couleur_4mod) } + # browser() + + # if(code_departement %in% c(08)){ + # fond <- ggplot2::ggplot() + + # ggplot2::geom_rect(data = dpt_shp, + # xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, + # fill = "black") + # } else { + # fond <- ggplot2::ggplot() + + # ggplot2::geom_rect(data = dpt_shp, + # xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, + # fill = "lightblue") + # } - browser() ggplot2::ggplot() + - ggplot2::geom_sf(data = dptFR_shp , fill = "grey95") + + ggplot2::geom_sf(data = pays_front , fill = "grey90") + + ggplot2::geom_sf(data = dptFR_shp , fill = "floralwhite") + ggplot2::geom_sf(data = dpt_shp, fill = "grey70", lwd = 1.2) + @@ -171,9 +190,11 @@ produire_carte_statique <- function(onde_df_mois = NULL, 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), 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", 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 9bba272..2ec6cb2 100644 --- a/inst/rmarkdown/templates/rapport_mensuel_onde_dpt/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/rapport_mensuel_onde_dpt/skeleton/skeleton.Rmd @@ -1,5 +1,5 @@ --- -title: "Bilan zaza mensuel ONDE \nObservatoire national des étiages \nDépartement `r params$code_departement`" +title: "Bilan mensuel ONDE \nObservatoire national des étiages \nDépartement `r params$code_departement`" author: "OFB, DR `r params$region_dr`" date: "Campagne `r params$type_rapport` de `r params$mois_rapport` \nrapport créé le `r format(Sys.time(), '%d %B %Y')`" output: @@ -137,11 +137,6 @@ onde_bilan_ecoulement_annee_dpt <- force_complementaire = T) ``` -```{r} - -print("zaza") -``` - Actuellement, le **département `r params$code_departement`** est couvert par **`r nb_stations` stations** d'observations. Pour le département, les dernières campagnes : From 9bd22d7e95ebca58f404ffe951104d285a044260 Mon Sep 17 00:00:00 2001 From: OFB-GE Date: Mon, 11 May 2026 20:59:14 +0200 Subject: [PATCH 5/5] Nettoyage et commentaires --- R/produire_carte_statique.R | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/R/produire_carte_statique.R b/R/produire_carte_statique.R index 0ff8492..c746c84 100644 --- a/R/produire_carte_statique.R +++ b/R/produire_carte_statique.R @@ -76,7 +76,7 @@ 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) @@ -121,20 +121,6 @@ produire_carte_statique <- function(onde_df_mois = NULL, observations = stringr::str_wrap(lib_ecoul4mod, 12), couleurs = Couleur_4mod) } - # browser() - - # if(code_departement %in% c(08)){ - # fond <- ggplot2::ggplot() + - # ggplot2::geom_rect(data = dpt_shp, - # xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, - # fill = "black") - # } else { - # fond <- ggplot2::ggplot() + - # ggplot2::geom_rect(data = dpt_shp, - # xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, - # fill = "lightblue") - # } - ggplot2::ggplot() + ggplot2::geom_sf(data = pays_front , fill = "lightgrey") + @@ -190,7 +176,7 @@ produire_carte_statique <- function(onde_df_mois = NULL, 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), + 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), @@ -203,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",