Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions R/produire_carte_statique.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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 == {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

Expand Down