Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Exploration Lettre Eolien PV Trim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DREAL Pays de la Loire
Centre de Services de la Donnée
Exploration Lettre Eolien PV Trim
Commits
a5475a4d
Commit
a5475a4d
authored
3 years ago
by
Franck.Gaspard
Browse files
Options
Downloads
Patches
Plain Diff
retouche légère du script de chargement des données et remodelage de l'application shiny
parent
b9e34538
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
explo_eolien _shiny.R
+93
-26
93 additions, 26 deletions
explo_eolien _shiny.R
explo_eolien.R
+72
-50
72 additions, 50 deletions
explo_eolien.R
with
165 additions
and
76 deletions
explo_eolien _shiny.R
+
93
−
26
View file @
a5475a4d
library
(
shiny
)
library
(
shinydashboard
)
library
(
mapview
)
library
(
leaflet
)
library
(
leaflet.extras
)
library
(
tidyverse
)
library
(
dplyr
)
load
(
"eolien_shiny.RData"
)
ui
<-
fluidPage
(
tags
$
br
(),
tags
$
h4
(
paste0
(
"carte des mats et parcs Eoliens en Pays de la Loire au "
,
Sys.Date
())),
mapviewOutput
(
outputId
=
"map"
),
tags
$
br
(),
tags
$
h4
(
paste0
(
"tableau source DREAL au "
,
Sys.Date
())),
tableOutput
(
"tableau"
),
tags
$
br
(),
tags
$
h4
(
paste0
(
"tableau source Enedis au "
,
Sys.Date
())),
selectInput
(
inputId
=
"select_trim"
,
label
=
"selectionner la fin d'un trimestre"
,
choices
=
unique
(
enedis_production_hist_eol_photov_PDL
$
Fin.De.Trimestre
),
selected
=
"2021-12-31"
),
tableOutput
(
"tableau_hist"
)
)
load
(
"eolien_pv_trim_shiny.RData"
)
ui
<-
sidebarLayout
(
sidebarPanel
(
selectInput
(
inputId
=
"select_trim"
,
label
=
"selectionner un trimestre"
,
choices
=
unique
(
enedis_production_eol_photov
$
trimestre
)
%>%
sort
(),
selected
=
"2020.4"
),
tags
$
br
(),
tags
$
h4
(
paste0
(
"carte des parcs Eoliens en Pays de la Loire au "
,
Sys.Date
())),
mapviewOutput
(
outputId
=
"map_eolien"
)
),
mainPanel
(
fluidPage
(
box
(
width
=
5
,
tags
$
h4
(
"Eolien terrestre source DREAL"
),
tableOutput
(
"tableau_dreal"
)
),
box
(
width
=
7
,
tags
$
h4
(
"Eolien terrestre et Photovoltaïque source Enedis"
),
tableOutput
(
"tableau_enedis"
)
)
),
fluidPage
(
tabBox
(
type
=
"tabs"
,
width
=
12
,
height
=
1000
,
tabPanel
(
title
=
"parcs en instruction"
,
box
(
width
=
6
,
"carte des nouveaux parcs du trimestre"
,
mapviewOutput
(
outputId
=
"map_parc_instruction"
),
tableOutput
(
"liste_parc_instruction"
)
),
box
(
width
=
6
,
"tableau du stock des parcs en instruction ?"
,
tableOutput
(
"tableau_parc_instruction"
))
),
tabPanel
(
title
=
"parcs autorisés"
,
box
(
width
=
6
,
"carte"
),
box
(
width
=
6
,
"tableau"
)
),
tabPanel
(
title
=
"parcs en service"
,
box
(
width
=
6
,
"carte"
),
box
(
width
=
6
,
"tableau"
)
)
)
)
)
)
server
<-
function
(
input
,
output
,
session
)
{
output
$
map
<-
renderLeaflet
({
(
mapview
(
mats_eolien
,
legend
=
FALSE
)
+
mapview
(
parcs_eolien
,
color
=
"red"
,
col.regions
=
"#EFC2E4"
,
legend
=
FALSE
))
@
map
%>%
output
$
map
_eolien
<-
renderLeaflet
({
(
mapview
(
parcs_eolien
,
legend
=
FALSE
))
@
map
%>%
addFullscreenControl
()
})
output
$
tableau
<-
renderTable
({
output
$
tableau
_dreal
<-
renderTable
({
parcs_eolien_tableau
%>%
filter
(
trim_autorisation
<=
input
$
select_trim
)
%>%
synthese_dep
()
%>%
mutate_if
(
is.numeric
,
as.integer
)
})
output
$
tableau_hist
<-
renderTable
({
enedis_production_hist_eol_photov_PDL
%>%
filter
(
Fin.De.Trimestre
==
input
$
select_trim
&
Type.Production
==
"Eolien"
)
%>%
select
(
-
Type.Production
,
-
Fin.De.Trimestre
)
%>%
rename
(
dep
=
Code.D
?
partement
)
%>%
mutate_if
(
is.numeric
,
as.integer
)
output
$
tableau_enedis
<-
renderTable
({
enedis_trimestre
(
trim
=
input
$
select_trim
)
%>%
select
(
-
trimestre
)
%>%
mutate_if
(
is.numeric
,
as.integer
)
})
# etat_parc_instruction_trim("2020.3", indicateurs = TRUE) tableau
# etat_parc_instruction_trim("2020.4", indicateurs = FALSE, nouveau = TRUE) carte
etat_parc_instruction_trim_carte
<-
reactive
({
parcs_eolien
%>%
semi_join
(
etat_parc_instruction_trim
(
input
$
select_trim
,
indicateurs
=
FALSE
,
nouveau
=
TRUE
)
%>%
select
(
id_parc
))
})
output
$
map_parc_instruction
<-
renderLeaflet
({
(
mapview
(
etat_parc_instruction_trim_carte
(),
legend
=
FALSE
))
@
map
%>%
addFullscreenControl
()
})
output
$
liste_parc_instruction
<-
renderTable
({
etat_parc_instruction_trim
(
input
$
select_trim
,
indicateurs
=
FALSE
,
nouveau
=
TRUE
)
%>%
left_join
(
parcs_eolien
%>%
st_drop_geometry
())
%>%
select
(
dep
,
id_parc
,
nom_parc
,
puissance_en_instruction
)
})
output
$
tableau_parc_instruction
<-
renderTable
({
etat_parc_instruction_trim
(
input
$
select_trim
,
indicateurs
=
TRUE
)
})
}
shinyApp
(
ui
,
server
)
This diff is collapsed.
Click to expand it.
explo_eolien.R
+
72
−
50
View file @
a5475a4d
...
...
@@ -7,17 +7,19 @@ library(lubridate)
# remotes::install_github("pachevalier/tricky")
library
(
tricky
)
# Datapréparation SIGLOIRE ----------
mats_eolien_1
<-
sf
::
st_read
(
"https://catalogue.sigloire.fr/api/data/25823933-a92c-4d78-bacf-1cfcf339fd56"
)
%>%
# 1171 obs
mutate
(
id_mat
=
paste0
(
id_au
,
"_"
,
numero
))
# names(mats_eolien_1)
# [1] "gid" "id_parc" "id_poste" "id_au" "numero" "n_parcel" "ht_max" "ht_mat" "ht_nacelle"
# [10] "diam_rotor" "pu_nominal" "x_pc" "y_pc" "sys_coord" "alt_base" "etat_mat" "date_prod" "date_real"
# [19] "date_demol" "en_service" "srce_geom" "precis_pos" "geometry" "id_mat"
mats_eolien_2
<-
sf
::
st_read
(
"https://catalogue.sigloire.fr/api/data/bbc57d12-ce05-4ce4-a66f-bc17bff48d4f"
)
# 1171 obs
mapview
(
mats_eolien
,
legend
=
FALSE
)
#
mapview(mats_eolien, legend = FALSE)
# names(mats_eolien2)
# [1] "gid" "id_mat" "numero_parcelle" "hauteur_max"
...
...
@@ -28,12 +30,13 @@ mapview(mats_eolien, legend = FALSE)
parcs_eolien
<-
sf
::
st_read
(
"https://catalogue.sigloire.fr/api/data/15468f65-9217-4edb-bfc3-4e68942097ce"
)
%>%
# 219 obs
mutate
(
dep
=
substr
(
id_parc
,
1
,
2
))
mapview
(
parcs_eolien
,
color
=
"red"
,
col.regions
=
"#EFC2E4"
,
legend
=
FALSE
)
#
mapview(parcs_eolien, color= "red", col.regions="#EFC2E4", legend=FALSE)
# names(parcs_eolien)
# [1] "gid" "id_parc" "code_icpe" "id_zde"
# [5] "nom_parc" "exploitant" "date_crea" "puissance_autorisee"
# [9] "puissance_en_fonctionnement" "puissance_en_instruction" "geometry"
# [9] "puissance_en_fonctionnement" "puissance_en_instruction" "geometry" "dep"
# Jointure des 3 tables
parcs_eolien_mats
<-
select
(
parcs_eolien
,
id_parc
,
nom_parc
,
dep
,
date_crea
,
puissance_autorisee
,
...
...
@@ -46,6 +49,15 @@ parcs_eolien_mats <- select(parcs_eolien, id_parc, nom_parc, dep, date_crea, pui
starts_with
(
"puissance_"
),
starts_with
(
"nb_mats_"
)),
.
,
by
=
"id_mat"
)
%>%
mutate
(
dep
=
substr
(
id_parc
,
1
,
2
))
# names(parcs_eolien_mats)
# [1] "id_mat" "etat_eolienne" "etat_service" "etat_autorisation"
# [5] "etat_autorisation_mat" "date_depot" "date_derniere_decision" "date_realisation"
# [9] "nb_mats_demandes" "nb_mats_autorises" "puissance_nominale_parc" "puissance_nominale_eolienne"
# [13] "id_parc" "nom_parc" "dep" "date_crea"
# [17] "puissance_autorisee" "puissance_en_fonctionnement" "puissance_en_instruction" "etat_mat"
# [21] "en_service" "date_prod" "id_au" "pu_nominal"
# [25] "geometry"
# table des parcs avec info sur date autorisation et de dépot
parcs_eolien_tableau
<-
parcs_eolien_mats
%>%
st_drop_geometry
()
%>%
...
...
@@ -57,19 +69,27 @@ parcs_eolien_tableau <- parcs_eolien_mats %>%
# redressement de la base : une saisie par erreur au niveau de la date de production
mutate
(
trim_mes
=
if_else
(
is.na
(
trim_autorisation
),
NA_real_
,
trim_mes
))
%>%
select
(
dep
,
id_parc
,
etat_autorisation
,
starts_with
(
"trim_"
),
puissance_nominale_parc
,
nb_mats
)
%>%
distinct
()
distinct
()
%>%
mutate
(
trim_depot
=
as.character
(
trim_depot
),
trim_autorisation
=
as.character
(
trim_autorisation
),
trim_mes
=
as.character
(
trim_mes
))
## Exploitation des données SIGLOIRE --------------
# une fonction de mise en page partielle du tableau d'indicateurs à partir d'une liste de parcs
synthese_dep
<-
function
(
etat
=
parcs_eolien_tableau
)
{
group_by
(
etat
,
dep
)
%>%
summarise
(
nb_parcs
=
n
(),
puiss_MW
=
sum
(
puissance_nominale_parc
),
nb_mats
=
sum
(
nb_mats
),
.groups
=
"drop"
)
%>%
summarise
(
nb_parcs
=
n
(),
puiss_MW
=
sum
(
puissance_nominale_parc
),
nb_mats
=
sum
(
nb_mats
),
.groups
=
"drop"
)
%>%
# on ajoute la ligne du total régional
bind_rows
(
.
,
summarise
(
.
,
dep
=
"PDL"
,
nb_parcs
=
sum
(
nb_parcs
),
puiss_MW
=
sum
(
puiss_MW
),
nb_mats
=
sum
(
nb_mats
))
)
%>%
)
%>%
rename
(
zone
=
dep
)
}
}
# fonction de création de la liste des parcs en instruction du trimestre ou des indicateurs de synthèse correspondant
etat_parc_instruction_trim
<-
function
(
trimestre
=
"2020.4"
,
indicateurs
=
FALSE
,
nouveau
=
FALSE
)
{
...
...
@@ -78,88 +98,76 @@ etat_parc_instruction_trim <- function(trimestre = "2020.4", indicateurs = FALSE
filter
(
trim_depot
<=
trimestre
)
%>%
# on garde les parcs non_encore autorisés (ie on retire les autorisés avant la fin du trimestre)
filter
(
trim_autorisation
>
trimestre
|
is.na
(
trim_autorisation
))
# un argument pour restreindre la liste des parcs aux seules nouvelles entrées du trimestre
if
(
nouveau
)
{
result
<-
result
%>%
filter
(
trim_depot
==
trimestre
)
}
}
# un arguments pour produire le tableau de synthèse
if
(
indicateurs
)
{
result
<-
synthese_dep
(
result
)
%>%
rename_with
(
.fn
=
~
paste0
(
.x
,
"_en_instruction"
))
%>%
rename
(
zone
=
zone_en_instruction
)
}
}
return
(
result
)
}
}
# exemple d'utilisation
etat_parc_instruction_trim
(
"2020.3"
,
indicateurs
=
TRUE
)
etat_parc_instruction_trim
(
"2020.4"
,
indicateurs
=
FALSE
,
nouveau
=
TRUE
)
#
etat_parc_instruction_trim("2020.3", indicateurs = TRUE)
#
etat_parc_instruction_trim("2020.4", indicateurs = FALSE, nouveau = TRUE)
# fonction de création de la liste des parcs autorisés (en service ou non) du trimestre ou des indicateurs de synthèse correspondant
etat_parc_autorise_trim
<-
function
(
trimestre
=
"2020.4"
,
indicateurs
=
FALSE
,
nouveau
=
FALSE
)
{
result
<-
parcs_eolien_tableau
%>%
# on garde les autorisations enregistrées avant la fin du trimestre
filter
(
trim_autorisation
<=
trimestre
)
# un argument pour restreindre la liste des parcs aux seules nouvelles entrées du trimestre
if
(
nouveau
)
{
result
<-
result
%>%
filter
(
trim_autorisation
==
trimestre
)
}
}
# un arguments pour produire le tableau de synthèse
if
(
indicateurs
)
{
result
<-
synthese_dep
(
result
)
%>%
rename_with
(
.fn
=
~
paste0
(
.x
,
"_autorises"
))
%>%
rename
(
zone
=
zone_autorises
)
}
}
return
(
result
)
}
}
# exmeples
etat_parc_autorise_trim
(
"2020.3"
,
indicateurs
=
TRUE
)
etat_parc_autorise_trim
(
"2020.4"
,
indicateurs
=
FALSE
,
nouveau
=
TRUE
)
# exemples
# etat_parc_autorise_trim("2020.3", indicateurs = TRUE)
# etat_parc_autorise_trim("2020.4", indicateurs = FALSE, nouveau = TRUE)
# fonction de création de la liste des parcs en service du trimestre ou des indicateurs de synthèse correspondant
etat_parc_construits_trim
<-
function
(
trimestre
=
"2020.4"
,
indicateurs
=
FALSE
,
nouveau
=
FALSE
)
{
result
<-
parcs_eolien_tableau
%>%
# on garde les autorisations enregistrées avant la fin du trimestre
filter
(
trim_mes
<=
trimestre
)
# un argument pour restreindre la liste des parcs aux seules nouvelles entrées du trimestre
if
(
nouveau
)
{
result
<-
result
%>%
filter
(
trim_mes
==
trimestre
)
}
}
# un arguments pour produire le tableau de synthèse
if
(
indicateurs
)
{
result
<-
synthese_dep
(
result
)
%>%
rename_with
(
.fn
=
~
paste0
(
.x
,
"_en_service"
))
%>%
rename
(
zone
=
zone_en_service
)
}
}
return
(
result
)
}
}
etat_parc_construits_trim
(
"2020.3"
,
indicateurs
=
TRUE
)
etat_parc_construits_trim
(
"2020.4"
,
indicateurs
=
FALSE
,
nouveau
=
TRUE
)
# exemples
# etat_parc_construits_trim("2020.3", indicateurs = TRUE)
# etat_parc_construits_trim("2020.4", indicateurs = FALSE, nouveau = TRUE)
# donnees Enedis : Parc de production - Maille regionale & departementale - Repartition---------------
# lien internet :https://data.enedis.fr/explore/dataset/parc-des-installations-de-production-raccordees-par-departement-historique/
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
=
"."
)
%>%
fileEncoding
=
"UTF-8"
,
dec
=
"."
)
%>%
# données de la région Pays de la Loire
tricky
::
set_standard_names
()
# names(enedis_production)
...
...
@@ -167,33 +175,47 @@ enedis_production <- read.csv2("https://data.enedis.fr/explore/dataset/parc-des-
# [6] "type_production" "id_type_inj" "type_injection" "stockage_existence" "tranche"
# [11] "fin_de_trimestre" "nombre_installations" "puissance_mw" "geo_shape" "geo_point_2d"
enedis_production_eol_photov
_PDL
<-
enedis_production
%>%
filter
(
code_type_prod
%in%
c
(
100
,
200
))
%>%
# on garde l
a région et l'éolien +
photovoltaïque
mutate
(
trimestre
=
quarter
(
ymd
(
fin_de_trimestre
),
with_year
=
TRUE
))
%>%
enedis_production_eol_photov
<-
enedis_production
%>%
filter
(
code_type_prod
%in%
c
(
100
,
200
))
%>%
# on garde l
'éolien et le
photovoltaïque
mutate
(
trimestre
=
as.character
(
quarter
(
ymd
(
fin_de_trimestre
),
with_year
=
TRUE
))
)
%>%
select
(
code_departement
,
type_production
,
trimestre
,
nombre_installations
,
puissance_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
),
.groups
=
"drop"
)
%>%
summarise
(
zone
=
as.character
(
unique
(
code_departement
)),
nb
=
sum
(
nombre_installations
),
MW
=
round
(
sum
(
puissance_mw
),
digits
=
1
),
.groups
=
"drop"
)
%>%
group_by
(
type_production
,
trimestre
)
%>%
bind_rows
(
.
,
summarise
(
.
,
zone
=
"PDL"
,
nb
=
sum
(
nb
),
MW
=
sum
(
MW
),
.groups
=
"drop"
)
)
%>%
arrange
(
type_production
)
%>%
select
(
-
code_departement
)
%>%
filter
(
!
is.na
(
nb
))
filter
(
!
is.na
(
nb
))
%>%
ungroup
()
# une fonction de filtre et de mise en forme pour le trimestre des données Enedis
enedis_trimestre
<-
function
(
trim
=
2020.4
)
{
filter
(
enedis_production_eol_photov
_PDL
,
trimestre
==
trim
)
%>%
enedis_trimestre
<-
function
(
trim
=
"
2020.4
"
)
{
filter
(
enedis_production_eol_photov
,
trimestre
==
trim
)
%>%
pivot_wider
(
id_cols
=
c
(
trimestre
,
zone
),
values_from
=
c
(
nb
,
MW
),
names_from
=
type_production
,
names_glue
=
"{type_production}_{.value}"
)
%>%
ungroup
()
%>%
select
(
trimestre
,
zone
,
starts_with
(
"Eol"
),
starts_with
(
"Pho"
))
}
}
# exemple
# enedis_trimestre("2020.4")
enedis_trimestre
(
2020.4
)
# sauvegarde jeux de données et fonctions utiles
save
(
parcs_eolien_mats
,
parcs_eolien
,
parcs_eolien_tableau
,
enedis_production_eol_photov_PDL
,
etat_parc_autorise_trim
,
etat_parc_construits_trim
,
etat_parc_instruction_trim
,
enedis_trimestre
,
# sauvegarde jeux de données et fonctions utiles --------------
save
(
parcs_eolien_mats
,
parcs_eolien
,
parcs_eolien_tableau
,
synthese_dep
,
etat_parc_autorise_trim
,
etat_parc_construits_trim
,
etat_parc_instruction_trim
,
enedis_production_eol_photov
,
enedis_trimestre
,
file
=
"eolien_pv_trim_shiny.RData"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment