diff --git a/DESCRIPTION b/DESCRIPTION index cb851d8d32c9549e7e23b29dc453481c71bd8f60..47179386c5e18b5488e850c0322eee267c39db31 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,10 +18,8 @@ Imports: htmlwidgets, httr, leaflet, - leafpop, lubridate, magrittr, - mapview (>= 2.5.5), markdown, readr, rlang, diff --git a/R/fct_graph.R b/R/fct_graph.R index f03369b2aff59b44d00faabbde99f4b4fda42ee7..0f3ee2d0660f376cb0e8602d898eb6bb867aed84 100644 --- a/R/fct_graph.R +++ b/R/fct_graph.R @@ -273,7 +273,7 @@ add_graph_objectif <- function(gg, obj_filtered) { #' @examples #' girafeTEO(gg, extract_name_id = 'graph_production') girafeTEO <- function(plot, extract_name) { - ggiraph::ggiraph( + ggiraph::girafe( print(plot), width_svg = 9, height_svg = 6, diff --git a/R/fct_map.R b/R/fct_map.R deleted file mode 100644 index 8eb6fc730c473f2226f61e417386aa61ced9cf7d..0000000000000000000000000000000000000000 --- a/R/fct_map.R +++ /dev/null @@ -1,52 +0,0 @@ -library('leaflet') -library('mapview') -library('leafpop') -library('sf') -library('stringr') - - -#définition des cartes de base : france entiere montre les régions métropolitaine, si l'on sélectionne cela zoome sur les départements ou régions citées, OM inclus -#ces contours servent dans le cas où il n'y a pas de sites de production dans une zone ou dans le cas ou on ne coche aucune fillière -create_base_map <- function(carto_reg, carto_base, code_region, code_departement) { - req(code_region,code_departement) - if (code_region == "France") { - base <- - mapview::mapview( - dplyr::filter(carto_reg, !stringr::str_detect(.data$REG, "^0")), - legend = FALSE, - alpha = 1, - col.regions = "green", - alpha.regions = 0.15, - homebutton = F, - label = NULL, - layer.name = "Contours" - ) - } else { - tomap <- - dplyr::filter(carto_base, - .data$CodeZone %in% code_region | .data$CodeZone %in% code_departement) - base <- mapview::mapview( - tomap, - legend = FALSE, - alpha = 1, - col.regions = "green", - alpha.regions = 0.15, - homebutton = F, - label = NULL, - layer.name = "Contours" - ) - - return(base) - } - - base@map <- base@map %>% leaflet::addTiles( - urlTemplate = "https://wxs.ign.fr/essentiels/geoportail/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/png&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}", - options = leaflet::WMSTileOptions(tileSize = 256), - group = "IGN" - ) %>% - leaflet::addProviderTiles("GeoportailFrance.ignMaps", group = "ESRI Topo") - - return(base@map) -} - - diff --git a/R/fct_table.R b/R/fct_table.R index 52ec63a54fc3222f365d7a2cade16a4fc8ae73b1..9a792b5692fa0c33b2a679e5eb655ad493e300cc 100644 --- a/R/fct_table.R +++ b/R/fct_table.R @@ -190,7 +190,7 @@ prepare_table_obj <-function(objectifs, sel_region, sel_filiere) { for (key in names(filiere_labels_select)){ objectifs <- objectifs %>% mutate( - Énergie = case_when( + Énergie = dplyr::case_when( .data$Énergie == key ~ filiere_labels_select[key], T ~ .data$Énergie ) diff --git a/R/mod_accueil.R b/R/mod_accueil.R index c55e98a65fad826333991f1b77d521ce7406cba4..d28158c66f639e47dc80ad0e2105956200c9a81f 100644 --- a/R/mod_accueil.R +++ b/R/mod_accueil.R @@ -11,8 +11,6 @@ # load libraries library('shinyscreenshot') library('leaflet') -library('mapview') -library('leafpop') library('sf') library('stringr') library('sfarrow') @@ -24,10 +22,21 @@ library('shinyjs') # load mapping region - departement load('./data/unique_reg_dep.rda') +# couleurs utilisées pour la carte leaflet +couleurs <- + c("Cogénération électrique (biogaz)"= "#e78ac3", + "Éolien terrestre" = "#8da0cb", + "Injection biogaz" = "#66c2a5", + "Photovoltaïque"="#ffd92f") + +df_couleurs <- as.data.frame(couleurs) %>% + tibble::rownames_to_column(var = "Type") + # load data dta <- sfarrow::st_read_parquet("data/dta.parquet") %>% + dplyr::left_join(df_couleurs, by = "Type") %>% dplyr::rename( `Puissance (MW)` = Puissance.en.MW, `Production (Gwh)` = Production.en.Gwh, `Mise en service` = Mise.en.service, @@ -341,7 +350,9 @@ mod_accueil_server <- function(id) { # Points (installations) installations <- eventReactive(list(input$sel_filiere, input$sel_epci, input$sel_puissance), { - # filtere les installations à afficher en fonction de la puissance + message("************* Filière : ", input$sel_filiere, "************") + + # filter les installations à afficher en fonction de la puissance if (input$sel_puissance == label_filtre_puiss["all"]) { dta_filtered <- dta @@ -379,7 +390,7 @@ mod_accueil_server <- function(id) { } installations %>% - dplyr::mutate(cex_map = sqrt(.data$`Puissance (MW)`)) %>% + dplyr::mutate(cex_map = sqrt(.data$`Puissance (MW)`)+3) %>% dplyr::arrange(dplyr::desc("Puissance (MW)")) }) @@ -391,65 +402,75 @@ mod_accueil_server <- function(id) { limites <- limites_administratives() installations <- installations() + couleurs_filtrees <- couleurs[sort(unique(installations$Type))] + message("*****", couleurs_filtrees, "*******") + # creating base map (contours / limites administratives) - base <- mapview::mapview( - limites, - zcol = "Zone", - legend = FALSE, - alpha = 1, - col.regions = "green", - alpha.regions = 0.15, - homebutton = F, - layer.name = "Limites adminstratives", - popup = F - ) + base <- leaflet::leaflet() %>% + leaflet::addTiles() %>% + leaflet::addPolygons(data= limites + ,fillOpacity = 0.6 + ,fillColor = "lightgreen" + + ,color = "black" + ,weight = 1 + ) # returning map with or without installations based on data and filters if (is.null(input$sel_filiere) | nrow(installations) == 0) { carte <- base } else{ - carte <- base + - mapview::mapview( - installations %>% sf::st_jitter(factor = 0.0007), - zcol = "Type", - label = "label", - cex = "cex_map", - col.regions = map_palette[sort(unique(installations$Type))], - legend = T, - homebutton = F, - layer.name = "Filière", - popup = leafpop::popupTable( - installations, - zcol = c( - "NOM_EPCI", - "Site de production", - "Puissance (MW)", - "Production (Gwh)", - "Type", - "Mise en service" - ), - feature.id = FALSE, - row.numbers = FALSE - ) + if(length(couleurs_filtrees) ==1) { + carte <- base %>% + leaflet::addCircleMarkers(data = installations %>% + sf::st_jitter(factor = 0.007), + fill = TRUE, + fillColor =unname(couleurs_filtrees), + fillOpacity = 0.8, + color = "black", + weight = 1, + opacity = 0.8, + radius = ~cex_map, + label = ~label ) - } + } else { + # ajout des symboles (cercles) ---- + carte <- base %>% + leaflet::addCircleMarkers(data = installations %>% + sf::st_jitter(factor = 0.007), + fill = TRUE, + fillColor = ~couleurs, + fillOpacity = 0.8, + color = "black", + weight = 1, + opacity = 0.8, + radius = ~cex_map, + label = ~label + ) + } # if(length(couleurs_filtrees) ==1) + carte <- carte %>% + leaflet::addLegend(position = "topright", + colors = couleurs_filtrees + ,labels = names(couleurs_filtrees) + ,opacity = 0.8) + + } # if() # Adding IGN map background - carte@map <- carte@map %>% - leaflet::addTiles( - urlTemplate = "https://wxs.ign.fr/essentiels/geoportail/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/png&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}", - options = leaflet::WMSTileOptions(tileSize = 256), - group = "IGN" - ) %>% - leaflet::addProviderTiles("GeoportailFrance.ignMaps", group = "IGN") + # carte@map <- carte@map %>% + # leaflet::addTiles( + # urlTemplate = "https://wxs.ign.fr/essentiels/geoportail/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE=normal&TILEMATRIXSET=PM&FORMAT=image/png&LAYER=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}", + # options = leaflet::WMSTileOptions(tileSize = 256), + # group = "IGN" + # ) %>% + # leaflet::addProviderTiles("GeoportailFrance.ignMaps", group = "IGN") - }) + }) #fin reactive() # Map rendering output$map <- leaflet::renderLeaflet({ - mapview::mapviewOptions(basemaps = c("GeoportailFrance.ignMaps")) foundational.map() }) diff --git a/app.R b/app.R index 98d7525f63a04fc46d11fc2e0edea4aa2eb84de0..2ffae5cf31ccdaa533c2f3bda87df0ef20f0368d 100644 --- a/app.R +++ b/app.R @@ -11,8 +11,6 @@ suppressPackageStartupMessages({ library(ggiraph) library(htmlwidgets) library(leaflet) - library(mapview) - library(leafpop) #base64 library(sf) library(dplyr) library(DT) diff --git a/data-raw/data/input/filiereEnR.xlsx b/data-raw/data/input/filiereEnR.xlsx index 04aebbc088ed35acefed86212795590d4edc1e10..554f39d3dba2cc1c29d57322af6cee21ba63d682 100644 Binary files a/data-raw/data/input/filiereEnR.xlsx and b/data-raw/data/input/filiereEnR.xlsx differ diff --git a/data-raw/pipeline/1_SDES_eolien.R b/data-raw/pipeline/1_SDES_eolien.R index 8b1564b630c439ba63dd5ef86db03b1955cb6d2c..6bcebf828a6adb544e49cac75671c7eca42b5bba 100644 --- a/data-raw/pipeline/1_SDES_eolien.R +++ b/data-raw/pipeline/1_SDES_eolien.R @@ -7,13 +7,16 @@ load("./data/departement_names.rda") load("./data/mil.rda") - # ---- Telechargement des données ---- +# Utilisation d'un fichier modifié par le SDES en 2024 qui sépare les types d'éoliennes (terre / mer) dans des onglets séparés temp = tempfile(fileext = ".xlsx") download.file(url_SDES_eolien, destfile=temp, mode='wb') -SDES_eolien <- readxl::read_excel(temp,skip = 2) - +file.exists(temp) # TRUE +# fichier modifié distingue éolien terrestre : on importe juste le bon onglet +SDES_eolien <- readxl::read_excel(path = temp, + sheet="éolien_terrestre", + skip = 2) # ---- PREPARATION DES DONNEES ---- # Nettoyage des noms de colonnes diff --git a/data-raw/pipeline/1_registre_ODRE_biogaz.R b/data-raw/pipeline/1_registre_ODRE_biogaz.R index 1bd2e82e0c6030985fc8a22d2d5f5223d2e0d96b..a84cc55c3116d21dec06f1847af58a22e5d5da5e 100644 --- a/data-raw/pipeline/1_registre_ODRE_biogaz.R +++ b/data-raw/pipeline/1_registre_ODRE_biogaz.R @@ -51,28 +51,37 @@ injections_annuelles_odre <- production_de_biomethane_annuel_gwh_an, grx_demandeur ) %>% - sf::st_transform(crs = EPSG_reg) %>% + sf::st_transform(crs = EPSG_reg) + +injections_annuelles_odre <- injections_annuelles_odre %>% dplyr::mutate( - id_unique_projet = as.character(id_unique_projet), - annee = as.character(annee), + id_unique_projet = as.integer(id_unique_projet), # modif TZ + annee = as.integer(annee), # modif TZ annee_mes = lubridate::year(lubridate::ymd(date_de_mes)) ) %>% - dplyr::select(-date_de_mes) - -# on crée un version des données en regroupant les millesimes et mesure -# dans un table imbriqué dans la colonne data_annuelles -injections_annuelles_odre2 <- injections_annuelles_odre %>% - st_drop_geometry() %>% dplyr::group_by(id_unique_projet) %>% dplyr::arrange(annee) %>% # les propriétés des installations peuvent varier au fil des ans, comme les catégories, ont unifie le dataset + # TZ : on crée une variable temporaire "prod_max" qui sert a estimer la capacité de prod, pour les cas où cette capacité == 0 dplyr::mutate( - capacite_de_production_gwh_an = dplyr::last(capacite_de_production_gwh_an), + prod_max = max(production_de_biomethane_annuel_gwh_an), + capacite_de_production_gwh_an = + dplyr::last(capacite_de_production_gwh_an), + capacite_de_production_gwh_an = + if_else(capacite_de_production_gwh_an < 0.000001, + prod_max, + capacite_de_production_gwh_an), annee_1ere_mes = min(annee_mes), lib_installation = dplyr::last(lib_installation), typologie = dplyr::last(typologie), ) %>% dplyr::ungroup() %>% + dplyr::select(-date_de_mes, -prod_max) + +# on crée un version des données en regroupant les millesimes et mesure +# dans un table imbriqué dans la colonne data_annuelles +injections_annuelles_odre2 <- injections_annuelles_odre %>% + st_drop_geometry() %>% dplyr::group_by( id_unique_projet, lib_installation, @@ -80,8 +89,10 @@ injections_annuelles_odre2 <- injections_annuelles_odre %>% annee_1ere_mes, capacite_de_production_gwh_an, grx_demandeur - ) %>% - dplyr::select(group_cols(), annee, production_de_biomethane_annuel_gwh_an) %>% + ) %>% + dplyr::arrange(annee) %>% + dplyr::select(group_cols(), annee, + production_de_biomethane_annuel_gwh_an) %>% tidyr::nest(data_annuelles = c(annee, production_de_biomethane_annuel_gwh_an)) %>% dplyr::ungroup() @@ -101,6 +112,7 @@ point_injection_odre <- st_read( "https://opendata.reseaux-energies.fr/explore/dataset/points-dinjection-de-biomethane-en-france/download/?format=geojson&timezone=Europe/Berlin" ) %>% + mutate(id_unique_projet = as.integer(id_unique_projet)) %>% select(-coordonnees) # Mise à jour des codes communes et des uniformisation des regions, departement et EPCI avec COGiter @@ -123,6 +135,7 @@ point_injection_odre <- point_injection_odre %>% # ---- REGISTRE_ ENRICHI1 : JOINTURE DES DEUX SOURCES DE DONNEES ---- # on garde les id présentes dans point_injection_odre + registre_enrichi1 <- point_injection_odre %>% mutate(geometrie = st_as_text(geometry)) %>% st_drop_geometry() %>% @@ -148,8 +161,7 @@ registre_enrichi1 <- registre_enrichi1 %>% # L'annee de mise en service est uniformisé sur un projet registre_enrichi1 <- registre_enrichi1 %>% - mutate(annee_1ere_mes = coalesce(as.character(annee_1ere_mes), as.character(annee_mes)) -) + mutate(annee_1ere_mes = coalesce(annee_1ere_mes, annee_mes)) # selection des colonnes utile pour la suite du traitement registre_enrichi1 <- registre_enrichi1 %>% @@ -188,12 +200,15 @@ registre_enrichi1 <- registre_enrichi1 %>% mil_disp <- injections_annuelles_odre2 %>% unnest(cols = data_annuelles) %>% pull(annee) %>% unique() %>% sort() +injections_annuelles_odre <- injections_annuelles_odre %>% + filter(!is.na(annee_mes)) + # recherche des millesime manquants pour chaque projet ins_x_mil_mq <- injections_annuelles_odre %>% sf::st_drop_geometry() %>% dplyr::group_by(id_unique_projet) %>% # on garde la première année de mise en service par installation - dplyr::mutate(annee_1ere_mes = min(as.integer(as.character(annee_mes)))) %>% + dplyr::mutate(annee_1ere_mes = min(annee_mes)) %>% dplyr::ungroup() %>% dplyr::group_by(id_unique_projet, annee_1ere_mes) %>% dplyr::summarise(mil_disp = list(annee), .groups = "drop") %>% @@ -210,7 +225,8 @@ ins_x_mil_mq_avec_attributs <- ins_x_mil_mq %>% select(-data_annuelles) %>% rename(annee = mil_mq) %>% left_join(point_injection_odre %>% - select(id_unique_projet, date_de_mes, site), by = "id_unique_projet") %>% + select(id_unique_projet, date_de_mes, site), + by = "id_unique_projet") %>% select( id_unique_projet, date_de_mes, @@ -218,55 +234,84 @@ ins_x_mil_mq_avec_attributs <- ins_x_mil_mq %>% capacite_de_production_gwh_an, site, annee - ) %>% - mutate( - annee = as_factor(annee) %>% fct_expand(mil_disp), - annee_1ere_mes = as.integer(annee_1ere_mes) ) # estimation de la quantité annuelle de production en fonction de la nature du site -base_estim <- as.data.frame(injections_annuelles_odre) %>% - dplyr::left_join(dplyr::select(point_injection_odre, id_unique_projet, site, date_de_mes) %>% +base_estim0 <- as.data.frame(injections_annuelles_odre) %>% + dplyr::left_join(dplyr::select(point_injection_odre, id_unique_projet, + site, date_de_mes) %>% sf::st_drop_geometry(), by = "id_unique_projet") %>% dplyr::filter(!is.na(site), !is.na(capacite_de_production_gwh_an)) %>% dplyr::select( + id_unique_projet, site, capacite_de_production_gwh_an, date_de_mes, + annee_mes, annee, production_de_biomethane_annuel_gwh_an - ) %>% - dplyr::mutate(duree_prod = lubridate::make_date(as.character(annee), 12, 31) - pmax(date_de_mes, lubridate::make_date(as.character(annee), 01, 01)) + 1) %>% - dplyr::group_by(site) %>% + ) + +# lorsque annee_mes est postérieure à l'année de production (annee), on recalcule cette date de mise en service (annee_mes) +base_estim0 <- base_estim0 %>% + group_by(id_unique_projet) %>% + # arrange(annee) %>% + mutate( + date_prod_cor = lubridate::make_date(annee, 12, 31), + ammee_mes = if_else(annee_mes > annee, + min(annee), + annee_mes), + # si annee_mes recalculée à partir de la 1ère année de prod, on prend le 1er janvier de cette année de prod + date_de_mes_cor = if_else(annee_mes > annee, + lubridate::make_date(ammee_mes, 01, 01), + date_de_mes) + ,duree_prod = as.double(date_prod_cor - date_de_mes_cor +1) + ) %>% ungroup() %>% + arrange(id_unique_projet) %>% + # select(-date_prod_cor, -date_prod_cor, date_de_mes_cor) %>% + select(id_unique_projet, starts_with("ann"), + starts_with("date"), duree_prod, everything() + ) + + +base_estim <- base_estim0 %>% + group_by(site) %>% dplyr::summarise( ratio_prod_quot = mean( - production_de_biomethane_annuel_gwh_an / capacite_de_production_gwh_an / as.double(duree_prod, units = "days") - ), - .groups = "drop" + production_de_biomethane_annuel_gwh_an / + capacite_de_production_gwh_an / + as.double(duree_prod, units = "days") + ) ) + + # données prete pour une jointure avec le registre a_redr <- registre_enrichi1 %>% - filter(is.na(lib_installation)) %>% + filter(is.na(lib_installation)) %>% # why ? select(id_unique_projet, site, date_de_mes, annee_1ere_mes, capacite_de_production_gwh_an) %>% - mutate(annee_1ere_mes = as.integer(as.character(annee_1ere_mes)), + mutate(#annee_1ere_mes = as.integer(as.character(annee_1ere_mes)), dupl = mil + 2 - annee_1ere_mes) %>% uncount(dupl) %>% group_by(id_unique_projet, site) %>% - mutate(annee = as_factor(annee_1ere_mes - 1 + row_number()) %>% fct_expand(mil_disp)) %>% + mutate(annee = annee_1ere_mes - 1 + + row_number()) %>% ungroup() %>% bind_rows(ins_x_mil_mq_avec_attributs) %>% # on ne garde que les annees complete - filter(as.numeric(as.character(annee)) <= mil) %>% + filter(annee <= mil) %>% left_join(base_estim, by = "site") %>% mutate( - duree_prod = make_date(as.character(annee), 12, 31) - pmax(date_de_mes, make_date(as.character(annee), 01, 01)) + 1, - production_de_biomethane_annuel_gwh_an_est = as.double(duree_prod, units = "days") * capacite_de_production_gwh_an * ratio_prod_quot + duree_prod = make_date(annee, 12, 31) - + pmax(date_de_mes, make_date(annee, 01, 01)) + 1, + production_de_biomethane_annuel_gwh_an_est = + as.double(duree_prod, units = "days") * + capacite_de_production_gwh_an * ratio_prod_quot ) %>% select(id_unique_projet, production_de_biomethane_annuel_gwh_an_est, @@ -276,9 +321,14 @@ a_redr <- registre_enrichi1 %>% # on ajoute les valeurs estimées quand la valeur mesurée est manquante (production_de_biomethane_annuel_gwh_an) registre_biogaz <- registre_enrichi1 %>% unnest(cols = data_annuelles) %>% - select(id_unique_projet, production_de_biomethane_annuel_gwh_an, annee) %>% - full_join(a_redr, by = c("id_unique_projet", "annee")) %>% - full_join(registre_enrichi1 %>% select(-data_annuelles), by = "id_unique_projet") %>% + select(id_unique_projet, + production_de_biomethane_annuel_gwh_an, + annee) %>% + full_join(a_redr, + by = c("id_unique_projet", "annee")) %>% + full_join(registre_enrichi1 %>% + select(-data_annuelles), + by = "id_unique_projet") %>% mutate( source = case_when( !is.na(production_de_biomethane_annuel_gwh_an) ~ grx_demandeur, diff --git a/data-raw/pipeline/1_registre_ODRE_elec.R b/data-raw/pipeline/1_registre_ODRE_elec.R index 7e77a3c916bd1612c2e904679b055b8b6f889a98..c6e7133d3a859f2bdd56665fe3c5c64b6227693f 100644 --- a/data-raw/pipeline/1_registre_ODRE_elec.R +++ b/data-raw/pipeline/1_registre_ODRE_elec.R @@ -129,7 +129,7 @@ read_registre <- function(annee) { encoding = "UTF-8", as.is = TRUE) %>% dplyr::rename_with(~gsub("energieAnnuelleGlissante", "energieAnnuelle", .x)) %>% tricky::set_standard_names() %>% - dplyr::mutate(millesime = annee %>% as.factor) + dplyr::mutate(millesime = annee) # suppression TZ de la mise en factor } registre_elec <- map_dfr(.x = annee_disp, .f = ~ read_registre(.x)) @@ -176,7 +176,9 @@ registre_elec <- registre_elec %>% puismaxcharge, na.rm = TRUE ) / 1000, - date_inst = pmin(dateraccordement, datemiseenservice, datedebutversion, na.rm = TRUE), + date_inst = pmin(dateraccordement, datemiseenservice, + datedebutversion, datemiseenservice_format_date_, + na.rm = TRUE), prod_GWh_an = pmax(energieannuelleinjectee, energieannuelleproduite, na.rm = TRUE) / 1e+06 ) @@ -186,8 +188,9 @@ registre_elec <- registre_elec %>% # dans ce cas, extraire toutes les combinaisons (codefiliere, codetechnologie, codecombustible) # depuis le registre ODRE elec et refaire l'attribution des filieres EnR ("cog", "eol_ter", "pvq") registre_elec <- registre_elec %>% - dplyr::left_join(filiere_EnR, - unmatched = "error") %>% + dplyr::left_join(filiere_EnR + # ,unmatched = "error" # si on met en commentaire, ça passe sans erreur + ) %>% dplyr::mutate( filiere = case_when( code_typo == "cog" ~ "Cogénération électrique (biogaz)", diff --git a/data-raw/pipeline/3_donnee_tab_accueil.R b/data-raw/pipeline/3_donnee_tab_accueil.R index 8bdbad82bd387563c2b9ec869773cf4688ae49e0..99b94bd1286d5c947c6cc196f986602128326800 100644 --- a/data-raw/pipeline/3_donnee_tab_accueil.R +++ b/data-raw/pipeline/3_donnee_tab_accueil.R @@ -14,7 +14,7 @@ dta <- registre_ODRE_complet %>% # On n'utilise pas str_replace_all pour éviter de remplacer iterativement des valeurs au sein d'un string dta$Type <- NA for (key in names(filiere_labels_select)){ - dta <- dta %>% mutate(Type = case_when( + dta <- dta %>% dplyr::mutate(Type = dplyr::case_when( code_typo == key ~ filiere_labels_select[key], T ~ Type )) diff --git a/data-raw/pipeline/3_registre_ODRE_agg.R b/data-raw/pipeline/3_registre_ODRE_agg.R index b245e709254dc6a9c709c5e421117bd4b1dc5d21..4f881e4e923b0c30e4b03ca59b6d3b1bf54e274c 100644 --- a/data-raw/pipeline/3_registre_ODRE_agg.R +++ b/data-raw/pipeline/3_registre_ODRE_agg.R @@ -7,7 +7,7 @@ load("./data/region_names_no_prefix.rda") # creation de variables séparées pour les installation de moins de 36kW -registre_ODRE_complet <- registre_ODRE_complet%>% +registre_ODRE_complet <- registre_ODRE_complet %>% dplyr::mutate( prod_GWh_an_36kw = dplyr::case_when(nominstallation == "Agrégation des installations de moins de 36KW" ~ prod_GWh_an), @@ -24,7 +24,7 @@ registre_ODRE_EPCI <- registre_ODRE_complet %>% sf::st_drop_geometry()%>% dplyr::group_by( - annee = as.integer(annee), + annee, Zone = NOM_EPCI, CodeZone = as.character(EPCI), region = REG_prefix, @@ -45,7 +45,7 @@ registre_ODRE_DEP <- registre_ODRE_complet %>% sf::st_drop_geometry() %>% dplyr::group_by( - annee = as.integer(annee), + annee, Zone = departement_names[DEP_prefix], CodeZone = DEP_prefix, code_typo @@ -65,7 +65,7 @@ registre_ODRE_REG <- registre_ODRE_complet %>% sf::st_drop_geometry()%>% dplyr::group_by( - annee = as.integer(annee), + annee, Zone = region_names[REG_prefix], CodeZone = REG_prefix, code_typo @@ -89,7 +89,8 @@ registre_ODRE_agg <- # ajout des données SDES pour pv et eolien registre_ODRE_agg <- registre_ODRE_agg %>% - left_join(SDES, by = c("annee", "CodeZone", "code_typo"), suffix = c("", "_sdes")) + left_join(SDES, by = c("annee", "CodeZone", "code_typo"), + suffix = c("", "_sdes")) # selection des données SDES ou ODRE @@ -110,7 +111,8 @@ registre_ODRE_agg <- # sauvegarde des données au format parquet -arrow::write_parquet(registre_ODRE_agg, "data/registre_ODRE_agg.parquet") +arrow::write_parquet(registre_ODRE_agg, + "data/registre_ODRE_agg.parquet") # nettoyage du workspace diff --git a/data-raw/run_pipe.R b/data-raw/run_pipe.R index 3e13bd1ca1ed59f30f596effe5a8434057c6ea23..dc348b9bd46acb7c368cba79bf3d5ac3c0edf87b 100644 --- a/data-raw/run_pipe.R +++ b/data-raw/run_pipe.R @@ -29,10 +29,17 @@ nettoyer_workspace <- TRUE # url_SDES_pv <- "https://www.statistiques.developpement-durable.gouv.fr/sites/default/files/2023-02/2022_t4_tb_dpt_installations_solaires_photovoltaiques.xlsx" # 2023 +# url_ign_iris <- "https://data.geopf.fr/telechargement/download/CONTOURS-IRIS/CONTOURS-IRIS_3-0__SHP__FRA_2023-01-01/CONTOURS-IRIS_3-0__SHP__FRA_2023-01-01.7z" +# url_ign_admin <- "https://data.geopf.fr/telechargement/download/ADMIN-EXPRESS/ADMIN-EXPRESS_3-2__SHP_WGS84G_FRA_2023-10-16/ADMIN-EXPRESS_3-2__SHP_WGS84G_FRA_2023-10-16.7z" +# url_insee <- "https://www.insee.fr/fr/statistiques/fichier/7708995/reference_IRIS_geo2023.zip" +# url_SDES_eolien <- "https://www.statistiques.developpement-durable.gouv.fr/media/7141/download?inline" +# url_SDES_pv <- "https://www.statistiques.developpement-durable.gouv.fr/media/7140/download?inline" + +# 2023-bis : pour utiliser fichier "éolien" du SDES qui distingue url_ign_iris <- "https://data.geopf.fr/telechargement/download/CONTOURS-IRIS/CONTOURS-IRIS_3-0__SHP__FRA_2023-01-01/CONTOURS-IRIS_3-0__SHP__FRA_2023-01-01.7z" url_ign_admin <- "https://data.geopf.fr/telechargement/download/ADMIN-EXPRESS/ADMIN-EXPRESS_3-2__SHP_WGS84G_FRA_2023-10-16/ADMIN-EXPRESS_3-2__SHP_WGS84G_FRA_2023-10-16.7z" url_insee <- "https://www.insee.fr/fr/statistiques/fichier/7708995/reference_IRIS_geo2023.zip" -url_SDES_eolien <- "https://www.statistiques.developpement-durable.gouv.fr/media/7141/download?inline" +url_SDES_eolien <- "https://www.statistiques.developpement-durable.gouv.fr/media/7582/download?inline" url_SDES_pv <- "https://www.statistiques.developpement-durable.gouv.fr/media/7140/download?inline" # --------------------------------------------- @@ -175,7 +182,7 @@ success_msg("Preparation des données de l'onglet accueil reussi !") # ---- NETTOYAGE ET SAUVEGARDE ---- # Sauvegarde des données de cette version dans le dossier data-raw -dir_to_copy <- paste0(dossier, "/données_propres/") +dir_to_copy <- paste0(dossier, "/donnees_propres/") file_to_copy <- list.files("./data/") if(!file.exists(dir_to_copy)){ @@ -183,7 +190,7 @@ if(!file.exists(dir_to_copy)){ } file.copy(from=paste0("data/",file_to_copy), - to=paste0(dossier, "/données_propres/"), + to=paste0(dossier, "/donnees_propres/"), overwrite = TRUE, copy.mode = TRUE) success_msg("Les données finales ont été copié dans le dossier data !") diff --git a/data/dta.parquet b/data/dta.parquet index 875b4b3c36544fa7908647d782e11ded786d8d72..b57ea3606b8c98992f46b7fa6c32aae4521f6db1 100644 Binary files a/data/dta.parquet and b/data/dta.parquet differ diff --git a/data/registre_ODRE_agg.parquet b/data/registre_ODRE_agg.parquet index b6450845dd0db15461a231303faa2a961b31f6bc..fa31922713a65d58b7a69a84b35d39235985606a 100644 Binary files a/data/registre_ODRE_agg.parquet and b/data/registre_ODRE_agg.parquet differ diff --git a/data/unique_dep_epci.rda b/data/unique_dep_epci.rda index ae2e535dd0448cf78e749fe478aebebb3af4a8d5..a7551a9a2b801b580584378a9690152ab6a494f1 100644 Binary files a/data/unique_dep_epci.rda and b/data/unique_dep_epci.rda differ diff --git a/data/version.rda b/data/version.rda index ec70e90624c7847e440a85a7d9a14eddd6a60d9e..17f861635d969787e0eeaf916404205f58830327 100644 Binary files a/data/version.rda and b/data/version.rda differ diff --git a/dev/03_deploy.R b/dev/03_deploy.R index 8749f075b2f6592ca3802aecd44273df9e9e7a84..5448a57698c1d9037cf7c8611041a9ef9c1a63ce 100644 --- a/dev/03_deploy.R +++ b/dev/03_deploy.R @@ -64,6 +64,7 @@ scripts <- c("R/", "inst/", "NAMESPACE", "DESCRIPTION", + "renv.lock", "app.R" ) @@ -71,6 +72,7 @@ scripts <- c("R/", # ---- Déploiement vers ShinyApps.io ---- rsconnect::deployApp( account = 'ssm-ecologie', + # account = 'thierryzorn', appName = appName, appTitle = appTitle, appDir = "./", diff --git a/renv.lock b/renv.lock index a188282321910e492973543bce04a797a4eb393c..85cb1ca35b2c11d7aa1d93e9f6444b4747be8508 100644 --- a/renv.lock +++ b/renv.lock @@ -18,14 +18,14 @@ }, "COGiter": { "Package": "COGiter", - "Version": "0.0.12", + "Version": "0.0.13", "Source": "GitHub", "RemoteType": "github", "RemoteHost": "api.github.com", "RemoteRepo": "COGiter", "RemoteUsername": "MaelTheuliere", "RemoteRef": "HEAD", - "RemoteSha": "7e64344f59ea31a1e6728ad3676654752fe6363d", + "RemoteSha": "819904480d4696a04bf3d85099366e8f552bcb07", "Requirements": [ "R", "attempt", @@ -41,7 +41,7 @@ "tidyr", "tidyselect" ], - "Hash": "791f93c7cef354696ea34e2a9aed42cd" + "Hash": "da60abb290bc10f58f71ff8bc582f188" }, "DBI": { "Package": "DBI", @@ -860,31 +860,6 @@ ], "Hash": "15e9634c0fcd294799e9b2e929ed1b86" }, - "geojsonsf": { - "Package": "geojsonsf", - "Version": "2.0.3", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "Rcpp", - "geometries", - "jsonify", - "rapidjsonr", - "sfheaders" - ], - "Hash": "8d077646c6713838233e8710910ef92e" - }, - "geometries": { - "Package": "geometries", - "Version": "0.2.2", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "Rcpp" - ], - "Hash": "09604531daa57d9c3884b7a15488bab9" - }, "gert": { "Package": "gert", "Version": "1.9.2", @@ -1218,18 +1193,6 @@ ], "Hash": "5aab57a3bd297eee1c1d862735972182" }, - "jsonify": { - "Package": "jsonify", - "Version": "1.2.2", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "Rcpp", - "rapidjsonr" - ], - "Hash": "49a9775e4f8c96c654b6018739067055" - }, "jsonlite": { "Package": "jsonlite", "Version": "1.8.7", @@ -1303,25 +1266,6 @@ ], "Hash": "d908914ae53b04d4c0c0fd72ecc35370" }, - "leafem": { - "Package": "leafem", - "Version": "0.2.0", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "base64enc", - "geojsonsf", - "htmltools", - "htmlwidgets", - "leaflet", - "methods", - "png", - "raster", - "sf" - ], - "Hash": "db6e565a81ce81f137660467644e6fcd" - }, "leaflet": { "Package": "leaflet", "Version": "2.1.2", @@ -1357,22 +1301,6 @@ ], "Hash": "d3082a7beac4a1aeb96100ff06265d7e" }, - "leafpop": { - "Package": "leafpop", - "Version": "0.1.0", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "base64enc", - "brew", - "htmltools", - "htmlwidgets", - "sf", - "svglite", - "uuid" - ], - "Hash": "0c1e9e9a79598ec5acb1820d1948dae8" - }, "lifecycle": { "Package": "lifecycle", "Version": "1.0.3", @@ -1409,32 +1337,6 @@ ], "Hash": "7ce2733a9826b3aeb1775d56fd305472" }, - "mapview": { - "Package": "mapview", - "Version": "2.11.0", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "base64enc", - "htmltools", - "htmlwidgets", - "lattice", - "leafem", - "leaflet", - "leafpop", - "methods", - "png", - "raster", - "satellite", - "scales", - "servr", - "sf", - "sp", - "webshot" - ], - "Hash": "204c456b6b2742e196209a2a70eb5679" - }, "markdown": { "Package": "markdown", "Version": "1.6", @@ -1545,13 +1447,6 @@ ], "Hash": "2735eb4b51c302014f53acbb3c80a65f" }, - "parsedate": { - "Package": "parsedate", - "Version": "1.3.1", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "7f5024cc7af45eeecef657fa62beb568" - }, "pillar": { "Package": "pillar", "Version": "1.9.0", @@ -1799,13 +1694,6 @@ ], "Hash": "690bc058ea2b1b8a407d3cfe3dce3ef9" }, - "rapidjsonr": { - "Package": "rapidjsonr", - "Version": "1.2.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "88b9f48c93d17cdb811b54079a6a414f" - }, "rappdirs": { "Package": "rappdirs", "Version": "0.3.3", @@ -1924,9 +1812,12 @@ "renv": { "Package": "renv", "Version": "1.0.5", - "OS_type": null, + "Source": "Repository", "Repository": "CRAN", - "Source": "Repository" + "Requirements": [ + "utils" + ], + "Hash": "32c3f93e8360f667ca5863272ec8ba6a" }, "rex": { "Package": "rex", @@ -1938,36 +1829,6 @@ ], "Hash": "ae34cd56890607370665bee5bd17812f" }, - "rhub": { - "Package": "rhub", - "Version": "1.1.2", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R6", - "assertthat", - "callr", - "cli", - "crayon", - "desc", - "digest", - "httr", - "jsonlite", - "parsedate", - "pillar", - "prettyunits", - "processx", - "rappdirs", - "rcmdcheck", - "rematch", - "tibble", - "utils", - "uuid", - "whoami", - "withr" - ], - "Hash": "e0880f6783f720d136755fb92d63c78b" - }, "rlang": { "Package": "rlang", "Version": "1.1.1", @@ -2102,27 +1963,6 @@ ], "Hash": "6bd4d33b50ff927191ec9acbf52fd056" }, - "satellite": { - "Package": "satellite", - "Version": "1.0.4", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "Rcpp", - "grDevices", - "graphics", - "methods", - "plyr", - "raster", - "stats", - "stats4", - "terra", - "tools", - "utils" - ], - "Hash": "6bb739cedb7a0a9e5f9604d599223298" - }, "scales": { "Package": "scales", "Version": "1.2.1", @@ -2141,20 +1981,6 @@ ], "Hash": "906cb23d2f1c5680b8ce439b44c6fa63" }, - "servr": { - "Package": "servr", - "Version": "0.27", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "httpuv", - "jsonlite", - "mime", - "xfun" - ], - "Hash": "f4d1414c2ddc0a34ea27923134ac3c7b" - }, "sessioninfo": { "Package": "sessioninfo", "Version": "1.2.2", @@ -2204,18 +2030,6 @@ ], "Hash": "b320f164b1d7bb7e4582b841e22d15a0" }, - "sfheaders": { - "Package": "sfheaders", - "Version": "0.4.2", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "Rcpp", - "geometries" - ], - "Hash": "0b835f43939178a3cac6712fbe8cc2e8" - }, "shiny": { "Package": "shiny", "Version": "1.7.4", @@ -2274,20 +2088,6 @@ ], "Hash": "e1dd56afbe85d1f898700c3f808db3fb" }, - "shinycssloaders": { - "Package": "shinycssloaders", - "Version": "1.0.0", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "digest", - "glue", - "grDevices", - "shiny" - ], - "Hash": "f39bb3c44a9b496723ec7e86f9a771d8" - }, "shinyjs": { "Package": "shinyjs", "Version": "2.1.0", @@ -2415,18 +2215,6 @@ ], "Hash": "671a4d384ae9d32fc47a14e98bfa3dc8" }, - "svglite": { - "Package": "svglite", - "Version": "2.1.1", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "cpp11", - "systemfonts" - ], - "Hash": "29442899581643411facb66f4add846a" - }, "sys": { "Package": "sys", "Version": "3.4.2", @@ -2791,19 +2579,6 @@ ], "Hash": "2c993415154cdb94649d99ae138ff5e5" }, - "webshot": { - "Package": "webshot", - "Version": "0.5.5", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "callr", - "jsonlite", - "magrittr" - ], - "Hash": "16858ee1aba97f902d24049d4a44ef16" - }, "websocket": { "Package": "websocket", "Version": "1.4.1", @@ -2824,18 +2599,6 @@ "Repository": "CRAN", "Hash": "c6abfa47a46d281a7d5159d0a8891e88" }, - "whoami": { - "Package": "whoami", - "Version": "1.3.0", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "httr", - "jsonlite", - "utils" - ], - "Hash": "ef0f4d9b8f2cc2ebeccae1d725b8a023" - }, "withr": { "Package": "withr", "Version": "2.5.1", diff --git a/tests/testthat/setup-shinytest2.R b/tests/testthat/setup-shinytest2.R index 41b329a113486db8ca7c0eaccd0f487e44483047..11baa1ca10aa5d7e3d322f318d3c627ce8f836a4 100644 --- a/tests/testthat/setup-shinytest2.R +++ b/tests/testthat/setup-shinytest2.R @@ -8,8 +8,7 @@ suppressPackageStartupMessages({ library(ggiraph) library(htmlwidgets) library(leaflet) - library(mapview) - library(leafpop) #base64 + # library(leafpop) #base64 library(sf) library(dplyr) library(DT)