Visualization on What Warms Our Earth

Natural and industrial factors on climate change from NASA

Inspired from the 2015 Bloomberg article on the subject, the purpose of this post is to remake the visualization with raw data from NASA through ggplot2 and shiny packages in R.

Click here to see the finished visualization.

Screenshot of the finished visualization in GIF format
Background

NASA, along with other environmental organizations, have been developing models that can predict the temperature change on Earth. Such models are usually extremely complicated by nature, as they intent to mimic different layers of our atmosphere, along with ocean and land. These models also include vast amount of factors that could have an impact on the temperature, including natural factors such as orbital change, solar energy absorbtion, and volcano activities, as well as human factors such as ozone pollution, deforestation, greenhouse gas emissions, and so on.

Objective

The objective is to show which factors have contributed the most to the climate change, in a visual-oriented and interactive manner.

Data Preparation

Raw datasets are provided below and NASA’s study can be found here.

Observed land-ocean temperature
Responses to climate forcings
850 year Preindustrial control experiment

The land-ocean temperature dataset contains observed temperature changes between 1880 and 2005. We will use this data to construct a benchmark of the average temperature between 1880 and 1910.

Responses to climate forcings include simulated temperatures with each corresponding factor. The temperature data is the average of 5 simulations from NASA’s model.

The 850 year Preindustrial control experiment is also the simulated temperature data from 1850 to 2700. However, we will only use the data range between 1880 and 2005, as this is the range of the observed temperature obtained.

It is common in climate change forecasting to examine the change in temperature, instead of the absolute values, as temperature measured varies by location and amplitude.

We also need to transform the raw data into the format below.

Screenshot of the prepared data

For the ease of the visualization and data processing, the standard 95% confidence interval along with 10-year moving average temperature change in climate change forecasting are not included in this post.

Visualization with R

The basic idea is simple, we will take in input values (factors) from users, and return the comparison between simulated temperature change and observed temperature change, in a 2-line plot. The server code may seem complicated at first, but its purpose is to return similar plot with factors changed only.

ui.R

We will create a user interface that takes into the factors desired.

library(ggplot2)
ui <- fluidPage(titlePanel("What is Really Warming the Earth?"),
br(),
fluidRow(
column(width=12,
h4("Check how much each factor contributed to global warming, based on NASA's studies."),
p("The change in temperature is a comparison to 1880-1990 average temperature."),
p("The grey line shows the observed land-ocean temperature between 1880-2005.")
)),
fluidRow(
column(width = 3, wellPanel(
radioButtons("factor", "Factors",
c("Orbital Changes",
"Solar",
"Volcanic",
"Aerosols",
"Land Use",
"Ozone",
"Greenhouse Gases",
"All Natural Factors",
"All Industrial Factors",
"All Factors")
))),
column(width = 5,
plotOutput("plot",height=350))),
hr(),
fluidRow(
column(width=12,
textOutput("topic"))
))

server.R

We will return the plot based on the factors selected through a number of if-then statements. Detailed explanation on the ggplot2 function was covered in the this post.

library(shiny)
library(shinydashboard)
library(ggplot2)
mydata <- read.csv("observed1.csv")
mydata$factor <- factor(mydata$factor, levels=unique(mydata$factor))
server <- function(input, output) {
output$plot <- renderPlot({
if (input$factor == "All Industrial Factors") {
ggplot(mydata[mydata$factor %in% c("Observed", "Human"),], aes(x=year))+geom_line(y=0,colour="grey")+geom_line(aes(y=temperature_change,colour=factor),size=1.05)+ylim(c(-1.5,1.5))+scale_colour_manual(values = c("gray45","cornflowerblue"))+ theme_bw()+theme(legend.position="none",panel.grid.major = element_blank(),panel.grid.minor = element_blank()) + labs(x="Year",y="Change in Temperature (C)")
}
else if (input$factor == "All Natural Factors") {
ggplot(mydata[mydata$factor %in% c("Observed", "Natural"),], aes(x=year))+geom_line(y=0,colour="grey")+geom_line(aes(y=temperature_change,colour=factor),size=1.05)+ylim(c(-1.5,1.5))+scale_colour_manual(values = c("gray45","peru"))+ theme_bw()+theme(legend.position="none",panel.grid.major = element_blank(),panel.grid.minor = element_blank()) + labs(x="Year",y="Change in Temperature (C)")
}
else if (input$factor == "All Factors") {
ggplot(mydata[mydata$factor %in% c("Observed", "All"),], aes(x=year))+geom_line(y=0,colour="grey")+geom_line(aes(y=temperature_change,colour=factor),size=1.05)+ylim(c(-1.5,1.5))+scale_colour_manual(values = c("gray45","hotpink"))+ theme_bw()+theme(legend.position="none",panel.grid.major = element_blank(),panel.grid.minor = element_blank()) + labs(x="Year",y="Change in Temperature (C)")
}
else if (input$factor == "Aerosols") {
ggplot(mydata[mydata$factor %in% c("Observed", "Aerosols"),], aes(x=year))+geom_line(y=0,colour="grey")+geom_line(aes(y=temperature_change,colour=factor),size=1.05)+ylim(c(-1.5,1.5))+scale_colour_manual(values = c("gray45","skyblue"))+ theme_bw()+theme(legend.position="none",panel.grid.major = element_blank(),panel.grid.minor = element_blank()) + labs(x="Year",y="Change in Temperature (C)")
}
else if (input$factor == "Greenhouse Gases") {
ggplot(mydata[mydata$factor %in% c("Observed", "Greenhouse gases"),], aes(x=year))+geom_line(y=0,colour="grey")+geom_line(aes(y=temperature_change,colour=factor),size=1.05)+ylim(c(-1.5,1.5))+scale_colour_manual(values = c("gray45","green3"))+ theme_bw()+theme(legend.position="none",panel.grid.major = element_blank(),panel.grid.minor = element_blank()) + labs(x="Year",y="Change in Temperature (C)")
}
else if (input$factor == "Land Use") {
ggplot(mydata[mydata$factor %in% c("Observed", "Land use"),], aes(x=year))+geom_line(y=0,colour="grey")+geom_line(aes(y=temperature_change,colour=factor),size=1.05)+ylim(c(-1.5,1.5))+scale_colour_manual(values = c("gray45","tan"))+ theme_bw()+theme(legend.position="none",panel.grid.major = element_blank(),panel.grid.minor = element_blank()) + labs(x="Year",y="Change in Temperature (C)")
}
else if (input$factor == "Ozone") {
ggplot(mydata[mydata$factor %in% c("Observed", "Ozone"),], aes(x=year))+geom_line(y=0,colour="grey")+geom_line(aes(y=temperature_change,colour=factor),size=1.05)+ylim(c(-1.5,1.5))+scale_colour_manual(values = c("gray45","violet"))+ theme_bw()+theme(legend.position="none",panel.grid.major = element_blank(),panel.grid.minor = element_blank()) + labs(x="Year",y="Change in Temperature (C)")
}
else if (input$factor == "Orbital Changes") {
ggplot(mydata[mydata$factor %in% c("Observed", "Orbital changes"),], aes(x=year))+geom_line(y=0,colour="grey")+geom_line(aes(y=temperature_change,colour=factor),size=1.05)+ylim(c(-1.5,1.5))+scale_colour_manual(values = c("gray45","turquoise3"))+ theme_bw()+theme(legend.position="none",panel.grid.major = element_blank(),panel.grid.minor = element_blank()) + labs(x="Year",y="Change in Temperature (C)")
}
else if (input$factor == "Solar") {
ggplot(mydata[mydata$factor %in% c("Observed", "Solar"),], aes(x=year))+geom_line(y=0,colour="grey")+geom_line(aes(y=temperature_change,colour=factor),size=1.05)+ylim(c(-1.5,1.5))+scale_colour_manual(values = c("gray45","orange"))+ theme_bw()+theme(legend.position="none",panel.grid.major = element_blank(),panel.grid.minor = element_blank()) + labs(x="Year",y="Change in Temperature (C)")
}
else
ggplot(mydata[mydata$factor %in% c("Observed", "Volcanic"),], aes(x=year))+geom_line(y=0,colour="grey")+geom_line(aes(y=temperature_change,colour=factor),size=1.05)+ylim(c(-1.5,1.5))+scale_colour_manual(values = c("gray45","brown1"))+ theme_bw()+theme(legend.position="none",panel.grid.major = element_blank(),panel.grid.minor = element_blank()) + labs(x="Year",y="Change in Temperature (C)")
})

output$topic <- renderPrint({
if (input$factor == "All Industrial Factors") {
cat("These factors together match the observed temperature increase, particularily since 1950.")
}
else if (input$factor == "All Natural Factors") {
cat("It seems nautraul factors combined do not match the observed temperature increase between 1880 and 2005.")
}
else if (input$factor == "All Factors") {
cat("All factors examined together. Our next steps?")
}
else if (input$factor == "Aerosols") {
cat("Aerosols from coal-buring actually help cool the planet. Too bad they also cause acid rain.")
}
else if (input$factor == "Greenhouse Gases") {
cat("The level of greenhouse gases such as CO2 is increased significantly over the time period. According to our data, it shows strong positive correlation with the climate change.")
}
else if (input$factor == "Land Use") {
cat("Deforestation leads to a slight cooling effect because the dark forests are being replaced by lighter batches that reflect more sunlight.")
}
else if (input$factor == "Ozone") {
cat("Ozone pollution created closer to Earth makes the climate warmer. Though the overall effect is not significant.")
}
else if (input$factor == "Orbital Changes") {
cat("The shape of the Earth's orbital varies over time from being circular (low eccentricity) and elliptical (high eccentricity). In periods of high eccentricity, radiation exposure on Earth can accordingly fluctuate more wildly. However, its effect on temperature change is negligible according to our data.")
}
else if (input$factor == "Solar") {
cat("The rate at which solar energy reaches the Earth's surface depends on the season, time of day, cloudiness, and location. However, little effect on the climate change is observed.")
}
else
cat("Negative temperature change observed in some years, which may be because of the sulface chemicals released.")
})
}

Click here to see the finished visualization.

Detailed deployment method was also introduced in my previous post.


Questions, comments, or concerns?
jchen6912@gmail.com