Climate Change Data Analysis (Part 1) — Global Warming in India

Krishna Kanth
Beginner @ Data Science
3 min readFeb 1, 2017

I’m a Climate Change enthusiast and this is my first attempt at analyzing the data related to this topic. Please correct me if you feel that I’ve misinterpreted something. Also, you’re welcome to suggest me other ideas to present climate change data in a better manner. Will try them out in my next articles. Thanks!

Surface Temperatures of India in the last 50 Years:

The first graph shows the Average Temperatures of India in the last 50 years on Y-axis. The trend line starts at 24 degree C and the minimum recorded temperature is nearly 23.6 degree C. In the span of 50 years a constant rise in the temperature is clearly apparent.

Now, let’s take a look at the trend line of the past 25 years and 10 years in two separate graphs:

Now, if we look at the trend line of the past 25 years in the second graph, there is a raise of 0.2 degree C in 25 years.

And the third graph depicts a significant change in the surface temperatures of India. The minimum average temperature rose from 24.2 degree C to 24.5 degree C. That’ s 0.3 degree C raise in just 15 years.

It took 25 years for the temperatures to raise from 24.0 C to 24.2 C, but only 15 years to raise from 24.2 C to 24.5 C. That’s a 150% raise in the surface temperatures in just one and half decade.

By looking at all the three graphs, it is apparent that the surface temperatures of India are raising at a dangerous pace. If this continuous, in just a few more decades, India will face a lot of consequences of global warming additional to what it is already experiencing at its heart every year.

The below is the R code I’ve used for my analysis. The packages used in this analysis are lubridate for Date related operations and ggplot2 for visualization:

#Importing the dataset
data <- read.csv("../input/GlobalLandTemperaturesByCountry.csv")
#removing NA records
data <- na.omit(data)
#tail(IND_data, n=12)
names(data)

#Data Preparation
library(lubridate)

data$Year <- year(data$dt)

IND_data <- subset(data, Country == "India")
summary(IND_data)
str(IND_data)

#changing the date column from Factor to Date type
IND_data$dt <- as.Date(IND_data$dt)
str(IND_data)
#Extracting the Years of all the dates and adding it as a new column
IND_data$Year <- year(IND_data$dt)
names(IND_data)

#Aggregating the average temperatures year wise
Avg_temp_IND <- aggregate(AverageTemperature ~ Year, FUN=mean, data = IND_data)

#Data Visualizations
library(ggplot2)

#Plotting the increase in temperature in last 50 years
IND_50 <- subset(Avg_temp_IND, Year > 1963)

ggplot(IND_50, aes(Year, AverageTemperature)) +
geom_line(size = 2, aes(colour = AverageTemperature)) +
scale_colour_gradient(low="orange", high="red") +
scale_x_continuous(breaks=seq(1960, 2015, 5)) +
scale_y_continuous(breaks=seq(23.5, 26, 0.2)) +
theme(plot.background = element_rect(fill='NA') ,legend.key=element_rect(fill=NA)) +
geom_smooth(method = "lm", se=FALSE, color="red") +
ggtitle("Surface Temperature of India in the last 50 Years")

#Plotting the increase in temperature in last 25 years
IND_25 <- subset(Avg_temp_IND, Year > 1988)

ggplot(IND_25, aes(Year, AverageTemperature)) +
geom_line(size = 2, aes(colour = AverageTemperature)) +
scale_colour_gradient(low="orange", high="red") +
scale_x_continuous(breaks=seq(1990, 2015, 3)) +
scale_y_continuous(breaks=seq(23.5, 26, 0.2)) +
theme(plot.background = element_rect(fill='NA') ,legend.key=element_rect(fill=NA)) +
geom_smooth(method = "lm", se=FALSE, color="red") +
ggtitle("Surface Temperature of India in the last 25 Years")

#Plotting the increase in temperature in last 10 years
IND_10 <- subset(Avg_temp_IND, Year > 2003)

ggplot(IND_10, aes(Year, AverageTemperature)) +
geom_line(size = 2, aes(colour = AverageTemperature)) +
scale_colour_gradient(low="orange", high="red") +
scale_x_continuous(breaks=seq(2003, 2015, 1)) +
scale_y_continuous(breaks=seq(24, 26, 0.1)) +
theme(plot.background = element_rect(fill='NA') ,legend.key=element_rect(fill=NA)) +
geom_smooth(method = "lm", se=FALSE, color="red") +
ggtitle("Surface Temperature of India in the last 10 Years")

--

--