Visualizing Global Warming through Shiny

Steven Ginzberg
Posted on May 15, 2016

Contributed by Steven Ginsberg.He is currently in the NYC Data Science Academy 12 week full time Data Science Bootcamp program taking place between April 11th to July 1st, 2016. This post is based on his second class project - R Shiny, due on the 2nd week of the program.

My Shiny application (R Code) looks at historical temperatures in an effort to visualize global warming.  NOAA provides worldwide average monthly temperature recordings from this year going all the way back to 1743.  The full data set includes 465,000 records from 7,300 weather stations worldwide.  Filtering this data for the United States only reduced the data set to 181,000 records and 1,900 stations.  In addition, I decided to start the presentation at 1840, just before the number of stations started to

Number of US Weather Stations contributing to the Temperature database

Number of US Weather Stations contributing to the temperature database

increase.

Addtional data is available, such as minimums and maximums as well as precipitation information.  While it would be useful to include these in a variability study, I decided to put this off for another time.

Cleaning up the Data

The data was relatively clean right off the website.  The first issue I encountered was the missing data points were filled in with -9999, making averages and minimums useless.  So these were replaced with NA’s.  The temperatures were stored as degrees Celsius *100, and as integers.  So, divide by 100 to get the two decimal points, convert to Fahrenheit, and they’re good to go.

Avg Temp, all years, all stations

Avg Temp, all years, all stations

NA’s accounted for 83,000 data points or .68% of the total.  I tried replacing the NA’s using k nearest neighbors built into R, but the data set was too large for the memory available.  I did not feel Mean or Random methods were appropriate, so I left the NA’s and ignored them for all average calculations.

A potentially bigger problem than the NA’s was some bad data.  There was a small number of data points with temperatures over 200 degrees.  This throws off averages, maximums and the entire scale of the chart.  These were replaced with NA’s and I was ready to create the application.

The Application

The application is simple, with two views of the data, the Chart and a Map.  I used the Shiny dashboard to layout the components, and googleVis for visualizations.

The Chart View

The chart displayed average temperature over time.  The “Year” slider changed the start year, while the end year was fixed to 2016.  The “Month” slider allowed the user to change the averages period viewed, from 1 specific month, 12 months, or seasonally if desired.

For each data set selected, the red line shows the linear trend.  While useful, it is important to note it is not a scientifically or mathematically accurate proof for or against global warming for a few reasons:

  • Taking an average of monthly averages is mathematically inaccurate, and weighs months evenly regardless of the number of days in a month;
  • NA’s are just being ignored and there was no analysis whether there is any bias or relationship to these data points;
  • In addition to the above, there was no analysis of outliers, location bias, etc.
Average Temperature Chart from the application

Average Temperature Chart from the application

The Map View

The map view shows temperatures by location.  The “Year” slider selects the year to display (not a range of years this time) and the "Month" slider selects the months to include in the average.  In all cases, the temps range from blue/cold to orange/hot.  Green dots show NA’s.

View of US Historical Temperatures

View of US Historical Temperatures

Conclusion

Having played with the chart for a while, some interesting patterns emerge.  Generally, we see an upward trend in average temperatures.  However, during the past 20 years this seems to have leveled off.  In addition, during this period it appears Jan – Mar is getting colder, while the rest of the year is level or warmer.  Again, take this all with a grain of salt – this is an example of what can be done from a visual perspective rather than a complete statistically correct study.

About Author

Steven Ginzberg

Steven Ginzberg

Steven has spent a number of years performing systems development, financial analysis and management in a variety of companies. Most recently, Steven has been working with start-ups helping them go from conception of ideas, identifying technologies, and finally...
View all posts by Steven Ginzberg >

Leave a Comment

No comments found.

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

#python #trainwithnycdsa 2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python python machine learning python scrapy python web scraping python webscraping Python Workshop R R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp