Air pollution emissions in Helsinki
From Opasnet
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.
Contents
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]
# This is code Op_en7923/answer on page [[Air pollution emissions in Helsinki]] library(OpasnetUtils) library(ggplot2) 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 emission <- EvalOutput(emission) gp <- ggplot(emission@output, aes(x=Year, weight=emissionResult, fill=Sector))+geom_bar()+ facet_wrap(~City, scales="free_y")+ theme_gray(base_size=20)+ labs(y="CO2eq emissions (kton/a)") gp objects.latest("Op_en7923", code_name="caremission") # [[Air pollution emissions in Helsinki]] caremission <- EvalOutput(caremission) gpcar <- ggplot(caremission@output, aes(x=Year, weight=caremissionResult, fill=Vehicle))+geom_bar()+ facet_grid(Pollutant~Municipality, scales="free_y")+ theme_gray(base_size=20)+ labs(y="CO2eq emissions (kton/a)") gpcar 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") } |
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
# This is code Op_en7923/fuelUse on page [[Air pollution emissions in Helsinki]] library(OpasnetUtils) fuelUse <- Ovariable( "fuelUse", dependencies=data.frame( Name="HSYdata", Ident="Op_en2791/HSYdata" ), formula = function(...) { HSYdata$CO2 <- NULL levels(HSYdata$Sector) <- tolower(levels(HSYdata$Sector)) levels(HSYdata$Consumer) <- tolower(levels(HSYdata$Consumer)) colnames(HSYdata@output)[colnames(HSYdata@output)=="Sector"] <- "Sektori" # Data is in Finnish but title in English return(HSYdata) } ) objects.store(fuelUse) cat("Ovariable fuelUse stored.\n") |
# This is code Op_en7923/emission on page [[Air pollution emissions in Helsinki]] library(OpasnetUtils) emission <- Ovariable( "emission", dependencies=data.frame( Name=c("fuelUse","emfactor"), Ident=c("Op_en7923/fuelUse","Op_en2791/emfactor") ), formula = function(...) { out <- fuelUse * emfactor return(out) } ) objects.store(emission) cat("Ovariable emission stored.\n") |
# This is code Op_en7923/answer on page [[Air pollution emissions in Helsinki]] library(OpasnetUtils) library(ggplot2) objects.latest("Op_en7923", code_name="emission") # [[Air pollution emissions in Helsinki]] emission emission <- EvalOutput(emission) ggplot(emission@output, aes(x=Year, weight=emissionResult, fill=Sector))+geom_bar()+ facet_wrap(~City, scales="free_y")+ theme_gray(base_size=20)+ labs(y="CO2eq emissions (kton/a)") opbase.upload( oapply(unkeep(emission, sources=TRUE, prevresults=TRUE), cols="Iter", FUN=mean)@output, ident = ident, name = pagename, obj_type = "variable", subset = "Answer", act_type = "replace", language = "eng", who = wiki_username, rescol = "emissionResult" ) cat("Ovariable emission uploaded as the answer of this knowledge crystal page.\n") |
# This is code Op_en7923/caremission on page [[Air pollution emissions in Helsinki]] library(OpasnetUtils) library(ggplot2) caremission <- Ovariable( "caremission", dependencies = data.frame( Name=c("carkm","caremf"), Ident=c( "Op_en7926/carkm", # [[Road traffic in Helsinki]] "Op_en2989/caremf" # [[Emission factors for road transport]] ) ), formula = function(...) { out <- carkm * caremf / 1000 # Mkm * g/km --> kton return(out) } ) caremission@meta$unit <- "kton/a" ggplot(EvalOutput(caremission)@output, aes(x=Year, weight=caremissionResult, fill=Vehicle))+ geom_bar()+facet_wrap(~Pollutant, scales="free_y") objects.store(caremission) cat("Ovariable caremission stored.\n") |
Push indicator to HNH2035
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) |
# 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) } |