library(finnishgrid)
Read basic API specification at https://data.fingrid.fi/en/pages/api.
Register free user account at https://data.fingrid.fi/open-data-forms/registration/.
Optional: add API key as your environment variable (~/.Renviron)
FINGRID_OPENDATA_API_KEY=MY_SECRET_KEY_FROM_EMAIL
= "2021-01-01T00:00:00+0200"
start_time = "2021-01-03T00:00:00+0200"
end_time = NA # TODO: replace with right key or use .Renviron file user_key
Let’s get Finnish hourly electricity consumption and production time-series data for basic visualization.
<- electricity_consumption_FI_RTD(start_time = start_time,
elec_cons end_time = end_time,
user_key = user_key)
<- electricity_production_FI_RTD(start_time = start_time,
elec_prod end_time = end_time,
user_key = user_key)
<- min(elec_cons$value) # consumption
min_elec_cons <- max(elec_cons$value)
max_elec_cons
<- min(elec_prod$value) # production
min_elec_prod <- max(elec_prod$value)
max_elec_prod
<- max(max_elec_cons, max_elec_prod)
y_max <- min(min_elec_cons, min_elec_prod) y_min
plot(elec_cons$start_time, elec_cons$value, type = 'l',
col = "green", ylim = c(y_min, y_max),
ylab = "Produced/Consumed (MW)",
xlab = "Time", main = "Electricity")
lines(elec_prod$start_time, elec_prod$value, type = 'l', col = "blue")
legend("topright", c("Cons", "Prod"), fill = c("green", "blue"))
API page: https://data.fingrid.fi/en/dataset/electricity-consumption-in-finland
<- get_data(api_number = 124, # energy consumption
tmp start_time = start_time,
end_time = end_time,
user_key = NA)
summary(tmp)
#> start_time end_time value id
#> Min. :2021-01-01 00:00:00 Min. :2021-01-01 01:00:00 Min. : 8972 Min. :124
#> 1st Qu.:2021-01-01 12:00:00 1st Qu.:2021-01-01 13:00:00 1st Qu.: 9309 1st Qu.:124
#> Median :2021-01-02 00:00:00 Median :2021-01-02 01:00:00 Median : 9861 Median :124
#> Mean :2021-01-02 00:00:00 Mean :2021-01-02 01:00:00 Mean : 9856 Mean :124
#> 3rd Qu.:2021-01-02 12:00:00 3rd Qu.:2021-01-02 13:00:00 3rd Qu.:10318 3rd Qu.:124
#> Max. :2021-01-03 00:00:00 Max. :2021-01-03 01:00:00 Max. :11018 Max. :124