diff --git a/DESCRIPTION b/DESCRIPTION index c4c14e6ac3082afbba75d5e7f6c0e69bcc36f7b0..c1a9a69a1be58330d109ad2f16f8919bc179a840 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,7 +36,8 @@ Imports: stringr, tidyr, tricky, - utils + utils, + sf Suggests: knitr, rmarkdown, diff --git a/NAMESPACE b/NAMESPACE index 6226ea47718611849f81d2f5fefccb6a84fc9a2b..b930620cbe87ce07457a0a7c921cf052fb800661 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,7 @@ export("%>%") export(creer_carte_1_3) export(creer_carte_1_7) +export(creer_carte_3_2) export(creer_graphe_1_1) export(creer_graphe_1_4) export(creer_graphe_1_5) @@ -24,9 +25,12 @@ importFrom(forcats,fct_drop) importFrom(forcats,fct_inorder) importFrom(forcats,fct_relevel) importFrom(forcats,fct_reorder) +importFrom(forcats,fct_rev) importFrom(ggiraph,geom_point_interactive) importFrom(ggiraph,ggiraph) importFrom(ggplot2,aes) +importFrom(ggplot2,annotate) +importFrom(ggplot2,arrow) importFrom(ggplot2,coord_flip) importFrom(ggplot2,element_text) importFrom(ggplot2,facet_wrap) @@ -39,17 +43,23 @@ importFrom(ggplot2,scale_fill_manual) importFrom(ggplot2,scale_x_discrete) importFrom(ggplot2,scale_y_continuous) importFrom(ggplot2,theme) +importFrom(ggplot2,unit) importFrom(ggtext,element_markdown) importFrom(glue,glue) importFrom(gouvdown,scale_fill_gouv_discrete) importFrom(lubridate,make_date) importFrom(lubridate,year) importFrom(magrittr,"%>%") +importFrom(mapfactory,creer_carte_categorie_communes) importFrom(mapfactory,creer_carte_communes) importFrom(mapfactory,creer_carte_communes_prop) importFrom(mapfactory,fond_carto) importFrom(mapfactory,format_fr) importFrom(scales,number_format) +importFrom(sf,st_centroid) +importFrom(sf,st_coordinates) +importFrom(sf,st_geometry) +importFrom(sf,st_point_on_surface) importFrom(stats,quantile) importFrom(stringr,str_wrap) importFrom(tidyr,gather) diff --git a/R/creer_carte_3_2.R b/R/creer_carte_3_2.R new file mode 100644 index 0000000000000000000000000000000000000000..f9ae1ab0188bda78747488fc94b7fd9ec1cc5a35 --- /dev/null +++ b/R/creer_carte_3_2.R @@ -0,0 +1,158 @@ +#' Creation de la carte communale de l'etalement urbain +#' @description Carte communale de l'etalement urbain +#' +#' @param millesime_etalement_urbain une année parmi les millesimes sélectionnables par l'utilisateur, au format numerique. +#' @param police_annotation la police de caractère pour les annotations +#' @return Une carte +#' +#' @importFrom dplyr filter mutate +#' @importFrom forcats fct_rev +#' @importFrom lubridate make_date +#' @importFrom mapfactory fond_carto creer_carte_categorie_communes +#' @importFrom ggplot2 annotate arrow unit labs theme +#' @importFrom glue glue +#' @importFrom sf st_centroid st_geometry st_coordinates st_point_on_surface +#' +#' @export +#' +#' @examples +#' creer_carte_3_2() +creer_carte_3_2 <- function(millesime_etalement_urbain = 2018, + police_annotation = "sans") { + data <- etalement_urbain %>% + dplyr::filter( + .data$TypeZone == "Communes", + .data$date == lubridate::make_date(millesime_etalement_urbain, "01", "01") + ) %>% + dplyr::mutate( + indicateur_etalement_urbain = replace(.data$indicateur_etalement_urbain, .data$indicateur_etalement_urbain == "classe 4", "classe 3"), + indicateur_etalement_urbain = replace(.data$indicateur_etalement_urbain, .data$indicateur_etalement_urbain == "classe 5", "classe 3") + ) %>% + dplyr::mutate(indicateur_etalement_urbain = forcats::fct_rev(.data$indicateur_etalement_urbain)) + + fond_carte <- mapfactory::fond_carto(nom_reg = "Pays de la Loire") + + localisation_classe2b <- fond_carte$communes %>% + dplyr::filter(.data$DEPCOM == "72214") %>% + sf::st_centroid() %>% + sf::st_geometry() %>% + sf::st_coordinates() + + localisation_classe2a <- fond_carte$communes %>% + dplyr::filter(.data$DEPCOM == "44038") %>% + sf::st_point_on_surface() %>% + sf::st_geometry() %>% + sf::st_coordinates() + + # # reflexions sur automatisation du choix communes de référence + # ideal_class3_x <- 390000 #coordonnées du point ideal + # ideal_class3_y <- 6630000 + # choix_class3 <- data %>% + # dplyr::filter(indicateur_etalement_urbain == "classe 3") #on ne conserve que les class 3 + # # ajouter dans cette table une colonne avec les coordonnéesdu centre de la commune + # #et une autre avec celles du point ideal + # # creer une colonne avec une fonction qui calcule la distance entre les 2 colonnes précedentes + # # prendre la valeur la plus faible de cette colonne et extraire le code commune + # # utiliser ce code dans localisation_class_3 + + localisation_classe3 <- fond_carte$communes %>% + dplyr::filter(.data$DEPCOM == "85289") %>% + sf::st_point_on_surface() %>% + sf::st_geometry() %>% + sf::st_coordinates() + + localisation_classe6 <- fond_carte$communes %>% + dplyr::filter(.data$DEPCOM == "49041") %>% + sf::st_point_on_surface() %>% + sf::st_geometry() %>% + sf::st_coordinates() + + carte_3_2 <- mapfactory::creer_carte_categorie_communes( + data = data, + code_region = 52, + carto = fond_carte, + palette = "pal_gouv_div1", + inverse = TRUE, + indicateur = .data$indicateur_etalement_urbain, + titre = glue::glue("Etalement urbain en Pays de la Loire par commune \n entre 2011 et {millesime_etalement_urbain}"), + bas_de_page = glue::glue("Source : fichiers fonciers et observatoire\nde l'artificialisation des sols,\n calculs DREAL"), + suffixe = NULL + ) + + ggplot2::annotate("curve", + x = 350000, + y = 6818000, + xend = localisation_classe2b[1], + yend = localisation_classe2b[2], + color = "black", + arrow = ggplot2::arrow(length = ggplot2::unit(0.05, "inches")) + ) + + ggplot2::annotate("label", + x = 340000, + y = 6818000, + label = "Population et\nartificialisation d\u00e9croissent", + label.r = ggplot2::unit(0, "lines"), + size = 3, + family = police_annotation, + fill = "#D1D9FF", + color = "black" + ) + + ggplot2::annotate("curve", + x = 320000, + y = 6775000, + xend = localisation_classe2a[1], + yend = localisation_classe2a[2], + color = "black", + arrow = ggplot2::arrow(length = ggplot2::unit(0.05, "inches")) + ) + + ggplot2::annotate("label", + x = 320000, + y = 6775000, + label = "L'artificialisation\nprogresse moins vite\nque la population", + label.r = ggplot2::unit(0, "lines"), + size = 3, + family = police_annotation, + fill = "#55659D", + color = "white" + ) + + + ggplot2::annotate("curve", + x = 470000, + y = 6603000, + xend = localisation_classe3[1], + yend = localisation_classe3[2], + color = "black", + arrow = ggplot2::arrow(length = ggplot2::unit(0.05, "inches")) + ) + + ggplot2::annotate("label", + x = 470000, + y = 6603000, + label = "L'artificialisation\nprogresse plus vite\nque la population", + label.r = ggplot2::unit(0, "lines"), + size = 3, + family = police_annotation, + fill = "#FFE4E2", + color = "black" + ) + + ggplot2::annotate("curve", + x = 500000, + y = 6645000, + xend = localisation_classe6[1], + yend = localisation_classe6[2], + color = "black", + arrow = ggplot2::arrow(length = ggplot2::unit(0.05, "inches")) + ) + + ggplot2::annotate("label", + x = 500000, + y = 6645000, + label = "La population d\u00e9croit \net et l'artificialisation progresse", + label.r = ggplot2::unit(0, "lines"), + size = 3, + family = police_annotation, + fill = "#D6857B", + color = "white" + ) + + ggplot2::labs(y = "", x = "") + + ggplot2::theme(legend.position = "none") + + return(carte_3_2) +} diff --git a/R/data.R b/R/data.R index 9cb585b7431291fc39d812d3fd48718e59b2a48e..73a3290c9c8da2e148e8b48569bade691c5512a6 100644 --- a/R/data.R +++ b/R/data.R @@ -60,3 +60,16 @@ #' @source \url{https://agreste.agriculture.gouv.fr/agreste-web/disaron/W0020/detail/} "metadata_donnee" +#' Table contenant les différents indicateurs de l etalement urbain +#' +#' @encoding UTF-8 +#' @format Table de 119279 lignes et 191 colonnes: +#' \describe{ +#' \item{TypeZone}{Type de territoire} +#' \item{CodeZone}{Code du territoire} +#' \item{Zone}{Libellé du territoire} +#' \item{date}{Millésime de la source} +#' \item{indicateur_etalement_urbain}{indicateur etalement urbain} +#' } +#' @source \url{https://agreste.agriculture.gouv.fr/agreste-web/disaron/W0020/detail/} +"etalement_urbain" diff --git a/R/globals.R b/R/globals.R index 116aa04a7d12a8a93b6788d1f2468939c756a81f..4fe0d75bce6567c3279d7e4f49545e635cad43d9 100644 --- a/R/globals.R +++ b/R/globals.R @@ -1,3 +1,4 @@ utils::globalVariables( - c("teruti","result","observatoire_artificialisation",".data","variable","valeur") + c("teruti","result","observatoire_artificialisation",".data","variable", + "valeur","etalement_urbain") ) diff --git a/data-raw/dataprep.R b/data-raw/dataprep.R index 29dec11539b0be965ebc78f6022edde805b1a5f0..c02768d735e3ea2a3c4886069bf731c2e044a6ea 100644 --- a/data-raw/dataprep.R +++ b/data-raw/dataprep.R @@ -60,6 +60,10 @@ postgresqlpqExec(con_datamart, "SET client_encoding = 'windows-1252'") observatoire_artificialisation<-dbReadTable(con_datamart, c("portrait_territoires","cogifiee_observatoire_artificialisation")) +# chargement des indicateurs d'etalement urbain depuis SGBD +etalement_urbain<-dbReadTable(con_datamart, + c("portrait_territoires","indicateur_etalement_urbain")) + # chargement des tables cogifiées d'indicateurs territoriaux load("extdata/cogifiee_chargement_ocsge.RData") @@ -117,9 +121,16 @@ observatoire_artificialisation <- observatoire_artificialisation %>% TypeZone = iconv(TypeZone,to = "UTF-8")) %>% mutate(across(where(is.character),as.factor)) +etalement_urbain <- etalement_urbain %>% + filter(CodeZone %in% liste_52 | TypeZone == "Régions") %>% + mutate(Zone = iconv(Zone,to = "UTF-8"), + TypeZone = iconv(TypeZone,to = "UTF-8")) %>% + mutate(across(where(is.character),as.factor)) + rm(liste_52) usethis::use_data(result, overwrite = TRUE, internal = FALSE) usethis::use_data(teruti, overwrite = TRUE, internal = FALSE) usethis::use_data(observatoire_artificialisation, overwrite = TRUE, internal = FALSE) +usethis::use_data(etalement_urbain, overwrite = TRUE, internal = FALSE) usethis::use_data(metadata_donnee, overwrite = TRUE, internal = FALSE) diff --git a/data/etalement_urbain.rda b/data/etalement_urbain.rda new file mode 100644 index 0000000000000000000000000000000000000000..efd499a48116078048d4bd171d783df66d828347 Binary files /dev/null and b/data/etalement_urbain.rda differ diff --git a/devstuff_history.R b/devstuff_history.R index 245da718d9caa10f80a44cdef6838b8b7b71ee04..51dc4a0e530790dbdd356d3b4fa112aeeb98af6c 100644 --- a/devstuff_history.R +++ b/devstuff_history.R @@ -17,6 +17,7 @@ usethis::use_package("stats") usethis::use_package("glue") usethis::use_package("lubridate") usethis::use_package("mapfactory") +usethis::use_package("sf") usethis::use_dev_package("COGiter",remote = "maeltheuliere/COGiter") usethis::use_dev_package("gouvdown",remote = "spyrales/gouvdown") usethis::use_dev_package("mapfactory",remote = "gitlab::dreal-datalab/mapfactory") @@ -59,6 +60,11 @@ usethis::use_vignette("bd-ch2-4","bd- Chapitre 2 Graphe 4") usethis::use_r("creer_graphe_2_4") usethis::use_test("creer_graphe_2_4") +##creer_carte_3_2 +usethis::use_vignette("cb-ch3-2","cb- Chapitre 3 Carte 2") +usethis::use_r("creer_carte_3_2") +usethis::use_test("creer_carte_3_2") + ## ajout news.md usethis::use_news_md() diff --git a/inst/rmarkdown/templates/publication/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/publication/skeleton/skeleton.Rmd index bdfb7f9425abfe1d73e0453de9981643ac5fc5e7..b5dc28ad9c185af790ce1dd020b404921b4d5463 100644 --- a/inst/rmarkdown/templates/publication/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/publication/skeleton/skeleton.Rmd @@ -9,6 +9,7 @@ params: millesime_teruti: 2018 millesime_ocsge: 2017 millesime_obs_artif: 2019 + millesime_etalement_urbain: 2018 title: "L'artificialisation des sols en Pays de la loire en `r params$millesime_observatoire_artificialisation`" --- @@ -68,4 +69,9 @@ creer_carte_1_7( params$millesime_ocsge) ```{r graph conso espace departements 10 ans,fig.width=5,fig.height=7} creer_graphe_2_4( params$millesime_obs_artif) ``` +## Chapitre 3 +```{r carte communale de l etalement urbain,fig.width=9,fig.height=7} +creer_carte_3_2( params$millesime_etalement_urbain, + police_annotation = "Marianne") +``` diff --git a/man/creer_carte_3_2.Rd b/man/creer_carte_3_2.Rd new file mode 100644 index 0000000000000000000000000000000000000000..aa99a68660727550e467f89b72dc41454a48a998 --- /dev/null +++ b/man/creer_carte_3_2.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/creer_carte_3_2.R +\name{creer_carte_3_2} +\alias{creer_carte_3_2} +\title{Creation de la carte communale de l'etalement urbain} +\usage{ +creer_carte_3_2(millesime_etalement_urbain = 2018, police_annotation = "sans") +} +\arguments{ +\item{millesime_etalement_urbain}{une année parmi les millesimes sélectionnables par l'utilisateur, au format numerique.} + +\item{police_annotation}{la police de caractère pour les annotations} +} +\value{ +Une carte +} +\description{ +Carte communale de l'etalement urbain +} +\examples{ +creer_carte_3_2() +} diff --git a/man/etalement_urbain.Rd b/man/etalement_urbain.Rd new file mode 100644 index 0000000000000000000000000000000000000000..046fc39f0ded027aacdaa02535672ff92f6dd25c --- /dev/null +++ b/man/etalement_urbain.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\encoding{UTF-8} +\name{etalement_urbain} +\alias{etalement_urbain} +\title{Table contenant les différents indicateurs de l etalement urbain} +\format{ +Table de 119279 lignes et 191 colonnes: +\describe{ +\item{TypeZone}{Type de territoire} +\item{CodeZone}{Code du territoire} +\item{Zone}{Libellé du territoire} +\item{date}{Millésime de la source} +\item{indicateur_etalement_urbain}{indicateur etalement urbain} +} +} +\source{ +\url{https://agreste.agriculture.gouv.fr/agreste-web/disaron/W0020/detail/} +} +\usage{ +etalement_urbain +} +\description{ +Table contenant les différents indicateurs de l etalement urbain +} +\keyword{datasets} diff --git a/tests/testthat/test-creer_carte_3_2.R b/tests/testthat/test-creer_carte_3_2.R new file mode 100644 index 0000000000000000000000000000000000000000..2856fd21994222ed8534e2cbe0dc24604e8739de --- /dev/null +++ b/tests/testthat/test-creer_carte_3_2.R @@ -0,0 +1,7 @@ +test_that("creer_carte_3_2 fonctionne", { + + # Test que la carte est un ggplot + objet <- creer_carte_3_2(millesime_etalement_urbain = 2018) + testthat::expect_equal(attr(objet, "class"), c("gg","ggplot")) + +}) diff --git a/vignettes/cb-ch3-2.Rmd b/vignettes/cb-ch3-2.Rmd new file mode 100644 index 0000000000000000000000000000000000000000..1591ec9fc760e3b529780fc0e06a058856fce243 --- /dev/null +++ b/vignettes/cb-ch3-2.Rmd @@ -0,0 +1,32 @@ +--- +title: "cb- Chapitre 3 Carte 2" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{cb- Chapitre 3 Carte 2} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + echo = FALSE, + message = FALSE, + warning = FALSE, + error = FALSE, + comment = "#>", + fig.width = 9, + fig.height = 7 +) + +``` + +# Descriptif +La fonction `creer_carte_3_2()` produit la carte communale de l'étalement urbain. + +```{r setup} +library(propre.artificialisation) +library(gouvdown) +creer_carte_3_2(millesime_etalement_urbain=2018, + police_annotation = "Marianne") +``` diff --git a/vignettes/test.R b/vignettes/test.R index a502a18bd34b397527cc479643153e4b92e41774..93b194cf1560d8463775a317d0dde95f12b8ce48 100644 --- a/vignettes/test.R +++ b/vignettes/test.R @@ -1,67 +1,129 @@ -#' Creation du graphique des surfaces Naf cadastrees nouvellement artificialisées entre 2009 et 2019 en ha -#' @description Graphique en barres des surfaces Naf cadastrees nouvellement artificialisées par departement en ha -#' -#' @param millesime_obs_artif une année parmi les millesimes sélectionnables par l'utilisateur, au format numerique. -#' -#' @return Un diagramme en barres -#' -#' @importFrom dplyr filter select mutate group_by desc arrange -#' @importFrom forcats fct_inorder -#' @importFrom ggplot2 ggplot aes geom_bar labs scale_y_continuous theme geom_text geom_col scale_fill_manual -#' @importFrom scales number_format -#' @importFrom glue glue -#' @importFrom lubridate make_date -#' @importFrom tidyr spread gather -#' @importFrom tricky set_standard_names -#' @importFrom mapfactory format_fr -#' -#' @export -#' -#' @examples -#' creer_graphe_2_4(millesime_obs_artif=2019) +millesime_etalement_urbain=2018 -library(propre.artificialisation) -millesime_obs_artif <- 2019 -# Encoding(data$Zone) <- "UTF-8" -# Encoding(data$TypeZone) <- "UTF-8" -# guess_encoding(data, n_max = 1000) + data <- etalement_urbain %>% + dplyr::filter(.data$TypeZone == "Communes", + .data$date == lubridate::make_date(millesime_etalement_urbain,"01","01"))%>% + dplyr::mutate(indicateur_etalement_urbain = forcats::fct_rev(.data$indicateur_etalement_urbain)) -#calcul des millesimes extremes du graphique -millesime_debut <- millesime_obs_artif - 10 -millesime_fin <- millesime_obs_artif - 1 + fond_carte <- mapfactory::fond_carto(nom_reg = "Pays de la Loire") -# Creation de la table utile a la production du graphique -data <- observatoire_artificialisation %>% - dplyr::filter(.data$TypeZone == "D\u00e9partements") %>% - dplyr::select(Zone,date,flux_naf_artificialisation_total) %>% - dplyr::mutate(Zone = forcats::fct_drop(.data$Zone) %>% - forcats::fct_relevel(c("Loire-Atlantique", "Maine-et-Loire", "Mayenne", "Sarthe", "Vendée")), - flux_naf_artificialisation_total = flux_naf_artificialisation_total / 10000) %>% - dplyr::arrange(.data$Zone) %>% - dplyr::mutate(date = as.character(year(.data$date - 1))) %>% - dplyr::filter(.data$date < millesime_obs_artif, .data$date > millesime_obs_artif - 11) #conserve les 10 derniers millesimes + localisation_classe6 <- fond_carte$communes %>% + dplyr::filter(DEPCOM=="53125") %>% + sf::st_centroid() %>% + sf::st_geometry() %>% + sf::st_coordinates() -# creation du graphique -graph_2_4<-data %>% - ggplot2::ggplot() + - ggplot2::geom_bar(ggplot2::aes(x=.data$date,y=.data$flux_naf_artificialisation_total,fill = .data$Zone), - width = 0.6, stat="identity")+ - # ggplot2::geom_bar(ggplot2::aes(x=.data$date,y=.data$flux_naf_artificialisation_total,fill = .data$Zone), - # width = 0.6, stat="identity",position=ggplot2::position_dodge(width=5))+ - ggplot2::geom_text(ggplot2::aes(x= .data$date,y = .data$flux_naf_artificialisation_total-120,label = mapfactory::format_fr(.data$flux_naf_artificialisation_total,0), group =.data$Zone), color = "black", size=3)+ - ggplot2::labs(title= glue::glue("Consommation d'espaces naturels,\n agricoles et forestiers (Naf)"), - subtitle=glue::glue("de {millesime_debut} \u00e0 {millesime_fin}"), - x="",y="surface (ha)", - fill="", - caption = glue::glue("Source : DGFip/Cerema {millesime_obs_artif}"))+ - ggplot2::facet_wrap(Zone ~ ., ncol = 1)+ - ggplot2::theme(legend.position = "none", - strip.text.x = ggplot2::element_text(size=8, color="brown", - face="bold.italic"))+ - ggplot2::scale_fill_manual(values = gouvdown::gouv_palettes[["pal_gouv_qual2"]][1:5]) + localisation_classe2a <- fond_carte$communes %>% + dplyr::filter(DEPCOM=="44072") %>% + sf::st_point_on_surface() %>% + sf::st_geometry() %>% + sf::st_coordinates() -return(graph_1_5) + # # reflexions sur automatisation du choix communes de référence + # ideal_class3_x <- 390000 #coordonnées du point ideal + # ideal_class3_y <- 6630000 + # choix_class3 <- data %>% + # dplyr::filter(indicateur_etalement_urbain == "classe 3") #on ne conserve que les class 3 + # # ajouter dans cette table une colonne avec les coordonnéesdu centre de la commune + # #et une autre avec celles du point ideal + # # creer une colonne avec une fonction qui calcule la distance entre les 2 colonnes précedentes + # # prendre la valeur la plus faible de cette colonne et extraire le code commune + # # utiliser ce code dans localisation_class_3 + localisation_classe3 <- fond_carte$communes %>% + dplyr::filter(DEPCOM=="85289") %>% + sf::st_point_on_surface() %>% + sf::st_geometry() %>% + sf::st_coordinates() + localisation_classe5 <- fond_carte$communes %>% + dplyr::filter(DEPCOM=="49224") %>% + sf::st_point_on_surface() %>% + sf::st_geometry() %>% + sf::st_coordinates() + carte_3_2 <- mapfactory::creer_carte_categorie_communes(data = data, + code_region=52, + carto = fond_carte, + palette = "pal_gouv_o", + inverse = FALSE, + indicateur = .data$indicateur_etalement_urbain, + titre = glue::glue("Etalement urbain en Pays de la Loire par commune \n au 1er janvier {millesime_etalement_urbain}"), + bas_de_page = glue::glue("Source : {millesime_etalement_urbain}"), + suffixe = NULL + ) + + ggplot2::annotate("curve", + x = 350000, + y=6818000, + xend = localisation_classe6[1], + yend = localisation_classe6[2], + color = "#D66C58", + arrow = ggplot2::arrow(length = ggplot2::unit(0.05, "inches")) + ) + + ggplot2::annotate("label", + x = 350000, + y=6818000, + label="classe 6 :\nTerritoires pour lesquels \nla population décroit et \nl'artificialisation progresse", + label.r = ggplot2::unit(0,"lines"), + size = 3, + family = "Marianne", + fill = "#D66C58", + color = "white") + + ggplot2::annotate("curve", + x = 320000, + y=6760000, + xend = localisation_classe2a[1], + yend = localisation_classe2a[2], + color = "black", + arrow = ggplot2::arrow(length = ggplot2::unit(0.05, "inches")) + ) + + ggplot2::annotate("label", + x = 320000, + y=6760000, + label="classe 2a :\nTerritoires pour lesquels \nla population croit moins vite \nque l'artificialisation", + label.r = ggplot2::unit(0,"lines"), + size = 3, + family = "Marianne", + fill = "#FFF2F1", + color = "black") + + ggplot2::annotate("curve", + x = 470000, + y=6603000, + xend = localisation_classe3[1], + yend = localisation_classe3[2], + color = "black", + arrow = ggplot2::arrow(length = ggplot2::unit(0.05, "inches")) + ) + + ggplot2::annotate("label", + x = 470000, + y=6603000, + label="classe 3 :\nTerritoires pour lesquels \nla population croit moins vite \nque l'artificialisation", + label.r = ggplot2::unit(0,"lines"), + size = 3, + family = "Marianne", + fill = "#FFC9C2", + color = "black") + + ggplot2::annotate("curve", + x = 500000, + y=6643000, + xend = localisation_classe5[1], + yend = localisation_classe5[2], + color = "black", + arrow = ggplot2::arrow(length = ggplot2::unit(0.05, "inches")) + ) + + ggplot2::annotate("label", + x = 500000, + y=6643000, + label="classe 5 :\nTerritoires pour lesquels \nla population croit moins vite \nque l'artificialisation", + label.r = ggplot2::unit(0,"lines"), + size = 3, + family = "Marianne", + fill = "#F66E4E", + color = "black") + + + + return(carte_3_2) + +}