Climate change: Interactive Plotly Dash to discover our future prospective
Climate change: Interactive Plotly Dash to discover our future prospective

Data science to find out more about what is going on in cities, countries and our world and what will happen. Francesco Tontarelli May 28·8 min read

Authors: Camilla Massi (LI) Silvia Paolucci (LI) Francesco Tontarelli (LI)

***Link to the app***

Photo by Li-An Lim on Unsplash

In the last years, several institutions are providing data highlighting the rising trend of our planet’s temperatures. A trend that unfortunately has nothing positive in it.

For years, scientists have continued to issue warnings to make us aware of how important it is to keep this increase of temperatures as low as possible. Despite the various agreements made on this subject, things are not going exactly as we would have hoped, and the consequences are evident.

A multitude of studies claims that climate change is producing significant alterations on both animals and plants. Climate conditions are decisive factors in determining which flora and fauna species can live, grow, and reproduce in a particular geographic region. Some of them are strongly related to the climatic conditions to whom they have adapted that a slight increase in temperature, a small reduction in rainfall or an imperceptible alteration in another parameter can increase their vulnerability.

The glaciers at the poles keep on melting incessantly due to the too high temperatures. This causes major changes in the ecosystem, accelerating the extinction of animals that inhabit it (ex: bees, polar bears, koalas, seals and many others) and the rise of ocean levels.

Of course, not only the cold places on Earth show the consequences of climate change. Also, Africa that “contains about one-fifth of all known species of plants, mammals and birds in the world, as well as one-sixth of amphibians and reptiles” (Siegfried 1989), is showing consistent variations. These include changes in the habits of migratory birds and large mammals, reduction of coral reefs with consequent loss of biodiversity, a relevant resource for the African people.

Even in Italy, we have examples of the impact of climate changes. For instance, we can point out the fact that it is estimated that the Marmolada glacier, which is the largest of the Dolomites (World Heritage Site), will disappear in 15 years and the situation is getting worse and worse every year.

So, we thought it was relevant to provide evidence of what is happening to our planet, which is also the one we will continue to live for the rest of our lives unless discoveries are made. To this end, we thought it would be interesting to take advantage of the new technologies of Data Science and Data Analysis to develop a dashboard in Python that would clearly and explicitly highlight the climate changes we are witnessing (and of which we are the cause).

Dataset

We have chosen an open-source dataset published by Berkeley Earth. It is an American no-profit organization that has made the measurements together with various agencies, among which NASA stands out.

It contains information about the monthly average temperature of the Earth, the different countries and some specific cities, starting from 1750 up to over half of 2013. One of the pieces of information was the uncertainty of the measurement. It was too high in the first centuries so this led us to decide to exclude them and thus work only with the years between 1900 and 2012 regarding cities and towns, with those between 1900 and 2015 regarding the Earth.

Plotly

For all our charts we used Plotly, which is a free and open-source library. It implements a wide range of charts that are visually attractive and impressive. It also allows you to add different types of interactive contents such as animations, sliders, and many others.

Dash

Dash is a productive Python framework for building web analytics applications, with no JavaScript required, and it is tightly integrated with Plotly. Dash is ideal for building data visualization applications with highly customized user interfaces. Through a couple of simple schemes, Dash abstracts all the technologies and protocols that are required to build an interactive web-based application, which allows you to deploy applications to servers and then easily share them. In addition, because the applications are displayed in the web browser, Dash is inherently cross-platform.

Heroku

Heroku is a cloud programming platform designed to help to build and deploying online applications (PaaS). It has been one of the first to appear on the web and allow its users to develop, deploy and manage online apps and supports six programming languages, including Python.

Being a PaaS, the purpose of Heroku is to provide users with the computing resources necessary to distribute and run web-based apps on various platforms (e.g. Facebook).

App

***Link to the app***

This app is built through Dash and Plotly and consists of three tabs: Global, Country and City. Each one is an interactive dashboard that shows and reports various charts and analysis from 1900 and goes up to the first half of the last decade.

The plots collected in the Global tab are the most significant ones: they immediately show the global warming phenomenon and its evolution during the last century.

The linear graph on the left side shows Earth’s average temperature trend over the years and its forecast until 2050. As time passes, the growing trend is more and more evident and the prediction confirms what scientists have been repeating for a long time: if we do not fight against this trend the temperature will increase quickly, and things will only get worse.

Through an animated chart is also possible to visualize how the temperature has evolved for each country of the world by making a comparison between its colour and the colour scale legend on the side. We notice that compared to 1900 the temperature of almost every country has increased, as can be seen through the warmer tones on the map. Hovering the mouse over the different countries it is possible to observe this variation in different years.

The Country tab provides a more in-depth analysis of the temperature evolution by the country: you can focus your analysis on a specific country and a particular year using the dropdown menus at the top.

The first chart shows the trend and the forecast of the average temperature of the selected country until 2042. To give an example, we have focused on our country, Italy: also in this case, as the rise in Earth temperature, it is easy to notice an undoubtedly increasing trend, especially since the ’80s, which has led to a non-stop temperature rise that has resulted in an increase of more than 1° C since 1900.

The monthly distribution of the average temperature of the selected country over the years is visible in the top-right chart through a box plot. In this way, it is possible to know the minimum value, the first quartile, the median, the third quartile and the maximum value of the average temperature of a country for each month of the year. In addition, this representation highlights the outliers, which represent unusually hot or cold months compared to the temperatures recorded on average in the various months of other years. For example, if you select Italy, it is possible to notice outliers in June and August, both corresponding to extraordinarily high temperatures recorded in 2003. In fact, in the summer of that year, an intense heatwave hit the whole of Europe and caused at least 30,000 deaths across the continent.

At the bottom of the tab, we can find a histogram that shows the average temperatures of the different cities that belong to the selected country. The horizontal segment indicates the average temperature of the country and the columns of the histogram represent the average temperature of the cities. As we might expect, selecting Italy, the highest columns correspond to the southern cities.

Moving to the City tab, it is possible to investigate in detail the average temperatures of a city and its country through a linear graph.

The forecast of the average temperature of the selected city up to 2042 is also shown graphically in this tab. This forecast is in line with the overall increase in global temperatures, which makes us wonder how much the climate change phenomenon may continue and worsen in the future.

Conclusions

In conclusion, we hope we have clearly explained the problems of climate change and global warming and stimulated your interest in the subject. We aim to provide quantitative support on understanding the mutations our planet is experiencing and the impact that climate change and global warming have on our lives. It is not “only” a question of melting glaciers at the poles or increasing desertification because it regards all of us and for this reason we have to fight against climate changes.

The forecasts we have made show an unequivocal trend. It leads to unsafe and worrying perspectives that extends to 2050, that is the year which the world’s primary leaders set the goal of achieving zero emissions at the recent Leader Summit on Climate, but will these so-called climate targets be met? Will they be sufficient? Or will it be the usual “big words and little actions”?
['Francesco Tontarelli']
['Data Science', 'Plotly', 'Dashboard', 'Climate Change', 'Python']