Skip to content
Snippets Groups Projects
Commit 5f517a87 authored by Juliette Engelaere-Lefebvre's avatar Juliette Engelaere-Lefebvre
Browse files

modif téléchargement données enedis

modif trimestre selectionné par défaut (120 jours au lieu de 90 jours pour être certains que les données Enedis soient disponibles)
parent 6072baa0
No related branches found
No related tags found
No related merge requests found
.Rproj.user
.Rhistory
**.RData
......
......@@ -7,6 +7,7 @@ library(leaflet)
library(lubridate)
# remotes::install_github("pachevalier/tricky")
library(tricky)
library(jsonlite)
# une fonction qui rapatrie les dernières données sigloire sur l'éolien et les renvoie dans une liste de 5 tables --------
......@@ -276,24 +277,28 @@ custom_palette <- c("#7FDD4C", "#16B84E","black", "red") # Vert absinthe, Vert m
update_enedis <- function(){
message("Donn\u00e9es enedis : début de collecte")
# nom_fich <- tempfile()
# download.file(url = "https://data.enedis.fr/explore/dataset/parc-des-installations-de-production-raccordees-par-departement-historique/download/?format=csv&q=code_type_prod+%3C+201&refine.region=Pays+de+la+Loire&timezone=Europe/Berlin&lang=fr&use_labels_for_header=true&csv_separator=%3B",
# destfile = nom_fich)
url_api_enedis <- "https://data.enedis.fr/api/records/1.0/search/?dataset=parc-des-installations-de-production-raccordees-par-departement-historique&q=code_type_prod+%3C+201&rows=10000&facet=code_region&facet=region&facet=code_departement&facet=nom_departement&facet=type_production&facet=type_injection&facet=stockage_existence&facet=tranche&facet=fin_de_trimestre&refine.region=Pays+de+la+Loire"
reponse_enedis <- fromJSON(url_api_enedis)
enedis_production <- reponse_enedis$records$fields %>% tricky::set_standard_names()
enedis_production <- read.csv2("https://data.enedis.fr/explore/dataset/parc-des-installations-de-production-raccordees-par-departement-historique/download/?format=csv&refine.region=Pays+de+la+Loire&timezone=Europe/Berlin&lang=fr&use_labels_for_header=true&csv_separator=%3B",
fileEncoding = "UTF-8", dec = ".") %>% # données de la région Pays de la Loire
tricky::set_standard_names()
# names(enedis_production)
# [1] "code_region" "region" "code_departement" "nom_departement" "code_type_prod"
# [6] "type_production" "id_type_inj" "type_injection" "stockage_existence" "tranche"
# [11] "fin_de_trimestre" "nombre_installations" "puissance_mw" "geo_shape" "geo_point_2d"
# [1] "id_type_inj" "type_production" "fin_de_trimestre" "stockage_existence" "nb" "nom_departement" "code_region"
# [8] "region" "code_departement" "tranche" "code_type_prod" "type_injection" "mw" "geo_point_2d"
# [15] "geo_shape"
enedis_production_eol_photov <- enedis_production %>%
filter(code_type_prod == 100 | (code_type_prod == 200 & tranche == "d-]250;...[")) %>% # on garde le photovoltaïque et l'éolien de grande puissance
mutate(trimestre = as.character(quarter(ymd(fin_de_trimestre), with_year = TRUE)),
type_production = str_standardize(type_production) %>% gsub("photovoltaique", "PV", .)) %>%
select(code_departement, type_production, trimestre, nombre_installations, puissance_mw) %>%
select(code_departement, type_production, trimestre, nb, mw) %>%
group_by(code_departement, type_production, trimestre) %>%
summarise(zone = as.character(unique(code_departement)),
nb = sum(nombre_installations),
MW = round(sum(puissance_mw), digits = 1),
nb = sum(nb),
MW = round(sum(mw), digits = 1),
.groups = "drop"
) %>%
group_by(type_production, trimestre) %>%
......
......@@ -4,8 +4,8 @@ sidebarLayout(
width = 2,
selectInput(inputId = "select_trim",
label = "selectionner un trimestre",
choices = quarter(ymd(seq.Date(as.Date("2015-01-01"), Sys.Date()-90 , by = "quarter")), type = "year.quarter"),
selected = quarter(ymd(Sys.Date()-90), type = "year.quarter")
choices = quarter(ymd(seq.Date(as.Date("2015-01-01"), Sys.Date() - 90 , by = "quarter")), type = "year.quarter"),
selected = quarter(ymd(Sys.Date() - 120), type = "year.quarter")
),
actionButton(
inputId = "source",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment