Air pollution emissions in Helsinki: Difference between revisions
Jump to navigation
Jump to search
(→Answer) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
== Answer == | == Answer == | ||
<rcode name="answer" graphics=1 embed= | * Model run 12.12.2018 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=tYDyrFr6SqKZlwoK] | ||
<rcode name="answer" graphics=1 embed=0> | |||
# This is code Op_en7923/answer on page [[Air pollution emissions in Helsinki]] | # This is code Op_en7923/answer on page [[Air pollution emissions in Helsinki]] | ||
library(OpasnetUtils) | library(OpasnetUtils) | ||
library(ggplot2) | library(ggplot2) | ||
library(plotly) | library(plotly) | ||
library(httr) | |||
library(jsonlite) | |||
objects.latest("Op_en6007", code_name="hnh3035") # [[OpasnetUtils/Drafts]] combineLines, pushIndicatorGraph | |||
objects.latest("Op_en7923", code_name="emission") # [[Air pollution emissions in Helsinki]] emission | objects.latest("Op_en7923", code_name="emission") # [[Air pollution emissions in Helsinki]] emission | ||
Line 41: | Line 46: | ||
if(FALSE) { | if(FALSE) { | ||
# https://plot.ly/ggplot2/user-guide/#interactively-view-the-json-object | |||
pushIndicatorGraph(gpcar, "https://hnhteamy.fi/v1/indicator/8/") | |||
cat("Plotly graphs on vehile fleet and km POSTed to HNH server.\n") | |||
cat("Plotly graphs | |||
} | } | ||
</rcode> | </rcode> | ||
Line 166: | Line 170: | ||
objects.store(caremission) | objects.store(caremission) | ||
cat("Ovariable caremission stored.\n") | cat("Ovariable caremission stored.\n") | ||
</rcode> | |||
==== Push indicator to HNH2035 ==== | |||
<rcode label="Push emission indicators (new version)" embed=1> | |||
library(OpasnetUtils) | |||
library(quiltr) | |||
library(plotly) | |||
library(ggplot2) | |||
objects.latest("Op_en6007", code_name="hnh2035") # [[OpasnetUtils/Drafts]] combineLines, pushIndicatorGraph | |||
dat <- qload("jyrjola/hsy", "pks_khk_paastot") | |||
dat <- dat[dat$Kaupunki=="Helsinki" , ] | |||
dat <- as.data.frame(dat) | |||
teeplotly <- function(dat,sector,title) { | |||
emis <- as.data.frame(dat) | |||
emis$Sector <- emis[[sector]] | |||
emis <- aggregate(emis["Päästöt"], emis[c("Vuosi","Sector")], sum) | |||
tmp <- aggregate(emis["Päästöt"],emis["Vuosi"],sum) | |||
pred <- rbind( | |||
data.frame( | |||
Vuosi=c(2000,2035), | |||
Tyyppi="toteuma", | |||
Paastot = predict( | |||
lm(Päästöt ~ Vuosi, data=tmp[tmp$Vuosi!=1990,]), | |||
newdata=data.frame(Vuosi=c(2000,2035)) | |||
) | |||
), | |||
data.frame( | |||
Vuosi=c(2017,2035), | |||
Tyyppi="tavoite", | |||
Paastot= c( | |||
tmp$Päästöt[tmp$Vuosi==2017], | |||
tmp$Päästöt[tmp$Vuosi==1990]*0.2) | |||
) | |||
) | |||
emis <- emis[emis$Vuosi!=1990,] | |||
p_emis <- plot_ly() %>% | |||
add_trace( | |||
x = ~emis$Vuosi, y = ~emis$Päästöt, type = 'bar', | |||
color = ~emis$Sector, legendgroup="mitattu") %>% | |||
# add_trace( # This is commented out because it causes an error in push process | |||
# x = ~pred$Vuosi, y = ~pred$Paastot, | |||
# linetype = ~pred$Tyyppi, mode='lines', | |||
# type = 'scatter', legendgroup = "ennuste") %>% | |||
layout( | |||
barmode="stack", | |||
title=title, | |||
xaxis=list(title="Vuosi"), | |||
yaxis=list(title="Päästö CO2e kton/a") | |||
) | |||
return(p_emis) | |||
} | |||
# p <- teeplotly(dat,"Sektori1","Kasvihuonekaasupäästöt Helsingissä sektoreittain") | |||
# pushIndicatorGraph(p, paste0(urli,6,"/")) | |||
p <- teeplotly(dat[dat$Sektori1=="Liikenne",],"Sektori2","Liikenteen kasvihuonekaasupäästöt Helsingissä") | |||
pushIndicatorGraph(p, 24) | |||
p <- teeplotly(dat[dat$Sektori2=="Tieliikenne",],"Sektori3","Tieliikenteen kasvihuonekaasupäästöt Helsingissä") | |||
pushIndicatorGraph(p, 23) | |||
p <- teeplotly(dat[dat$Sektori2 %in% c("Raideliikenne","Laivaliikenne"),],"Sektori3","Raide- ja laivaliikenteen kasvihuonekaasupäästöt Helsingissä") | |||
pushIndicatorGraph(p, 67) | |||
p <- teeplotly(dat[dat$Sektori3=="Henkilöautot",],"Sektori4","Henkilöautojen kasvihuonekaasupäästöt Helsingissä") | |||
pushIndicatorGraph(p, 11) | |||
p <- teeplotly(dat[dat$Sektori1=="Sähkö",],"Sektori2","Sähköntuotannon kasvihuonekaasupäästöt Helsingissä") | |||
pushIndicatorGraph(p, 30) | |||
p <- teeplotly(dat[dat$Sektori1=="Lämmitys",],"Sektori2","Lämmöntuotannon kasvihuonekaasupäästöt Helsingissä") | |||
pushIndicatorGraph(p, 25) | |||
p <- teeplotly(dat[dat$Sektori2=="Öljylämmitys",],"Sektori4","Öljylämmityksen kasvihuonekaasupäästöt Helsingissä") | |||
pushIndicatorGraph(p, 35) | |||
# teeplotly(dat[dat$Sektori1=="Teollisuus ja työkoneet",],"Sektori2","Teollisuuden kasvihuonekaasupäästöt Helsingissä") | |||
# teeplotly(dat[dat$Sektori1=="Maatalous",],"Sektori2","Maatalouden kasvihuonekaasupäästöt Helsingissä") | |||
# teeplotly(dat[dat$Sektori1=="Jätteiden käsittely",],"Sektori2","Jätteenkäsittelyn kasvihuonekaasupäästöt Helsingissä") | |||
p <- teeplotly(dat[dat$Sektori1 %in% c("Teollisuus ja työkoneet","Maatalous","Jätteiden käsittely"),],"Sektori2","Teollisuuden, jätteenkäsittelyn ja maatalouden kasvihuonekaasupäästöt Helsingissä") | |||
pushIndicatorGraph(p, 66) | |||
</rcode> | |||
<rcode label="Push emission indicators to HNH2035 (for developers only)" embed=1> | |||
# This is code Op_en7923/answer on page [[Air pollution emissions in Helsinki]] | |||
library(OpasnetUtils) | |||
library(plotly) | |||
objects.latest("Op_en6007", code_name="hnh2035") # [[OpasnetUtils/Drafts]] combineLines, pushIndicatorGraph | |||
objects.latest("Op_en6007", code_name="miscellaneous") # [[OpasnetUtils/Drafts]] truncateIndex | |||
objects.latest("Op_en7923", code_name="caremission") # [[Air pollution emissions in Helsinki]] caremission | |||
caremission <- EvalOutput(caremission) | |||
tmp <- caremission[caremission$Municipality=="Helsinki" & caremission$Pollutant=="CO2eq",] | |||
tmp <- truncateIndex(oapply(tmp, cols="Location", FUN=sum), "Vehicle",6) | |||
p_caremission_co2 <- plot_ly( | |||
tmp@output, | |||
x = ~Year, y = ~caremissionResult, color = ~Vehicle, type = 'bar' | |||
) %>% | |||
layout(barmode='stack', title="Henkilöautojen kasvihuonekaasupäästöt", | |||
xaxis=list(title="Vuosi"),yaxis=list(title="CO2ekv-päästö (kton/vuosi)")) | |||
tmp <- caremission[caremission$Municipality=="Helsinki" & caremission$Pollutant=="PM2.5",] | |||
tmp <- truncateIndex(oapply(tmp, cols="Location", FUN=sum), "Vehicle",6) | |||
p_caremission_pm <- plot_ly( | |||
tmp@output, | |||
x = ~Year, y = ~caremissionResult, color = ~Vehicle, type = 'bar' | |||
) %>% | |||
layout(barmode='stack', title="Henkilöautojen pienhiukkaspäästöt", | |||
xaxis=list(title="Vuosi"),yaxis=list(title="PM2.5-päästö (kton/vuosi)")) | |||
pushIndicatorGraph(p_caremission_co2, "https://hnh.teamy.fi/v1/indicator/11/") | |||
pushIndicatorGraph(p_caremission_pm, "https://hnh.teamy.fi/v1/indicator/15/") | |||
cat("Private car CO2eq and PM2.5 emissions (indicators #11, #15) pushed to HNH2035.\n") | |||
if(FALSE) { | |||
objects.latest("Op_en7923", code_name="emission") # [[Air pollution emissions in Helsinki]] emission | |||
emission <- EvalOutput(emission) | |||
caremission <- EvalOutput(caremission) | |||
} | |||
</rcode> | </rcode> | ||
Latest revision as of 20:12, 8 February 2019
Moderator:Nobody (see all) Click here to sign up. |
This page is a stub. You may improve it into a full page. |
Upload data
|
Air pollution emissions in Helsinki estimate direct air pollution emissions (including CO2eq) from the Helsinki area.
Question
What are the amounts of air pollution (notably CO2eq and PM2.5) emitted from the Helsinki area (Helsinki specifically but also other municipalities of the Helsinki Metropolitan Area)?
Answer
- Model run 12.12.2018 [1]
Rationale
Dependencies
Calculations
The answer metadata can be obtained by using link: http://cl1.opasnet.org/opasnet_base_2/index.php?ident=op_en7923.answer&act=0
The actual data: (key is unique to every download instance and is generated when the above link is opened) - http://cl1.opasnet.org/opasnet_base_2/index.php?key=8dYqLbtppz4HM7sYaAyj4t6S49jQNRWJ