Data Visualizing air pollution levels in the USA

Posted on Jan 11, 2019
The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.


As a mechanical engineer, I am interested in engineering solutions that promote sustainability and a circular economy. Air pollution is a major contributor to health hazards and climate change. Therefore,as part of my first project at the NYC Data Science Academy, I have decided to create an R shiny application that models air pollution levels across various US cities. The project is based on my motivation to understand the seasonal and geographical patterns among various air pollutants.


I worked with a Dataset that provides the mean air quality index (AQI) for four pollutants of major cities in all 51 states. AQIs were calculated 4 times per day over the period of 01/01/2000 to 12/31/2010.

    • SO2: Sulfur Dioxide
    • CO: Carbon Monoxid
    • O3: Ozone
    • NO2:Nitrogen Dioxide

Data Visualizing air pollution levels in the USA

Pollution Calendar 

The first component of the app consists of a pollution calendar  that allows the user to examine  daily variations in air pollution from the year 2000 to 2010. The user selects the state, city , pollutant of interest and date range, displaying a calendar in the following format: 

Data Visualizing air pollution levels in the USA

The screenshot above provides a  NO2 pollution calendar for San Francisco-California over the period 2003-2008. Darker colors indicate a higher air quality index which implies more pollution. As NO2 is a pollutant that peaks during the heating season, we would expect lighter colors during the summer months (June, July, August), this is consistent with our calendar. On the other hand, Ozone air quality indices are expected to peak in the summer as demonstrated in New York city's pollution calendar (2003-2008).

Data Visualizing air pollution levels in the USA

Pollution By chemical

I have proceeded with BoxPlots that compare the pollution levels of various pollutants in the same city.  median pollution levels were grouped by month.

Screenshot 2019-01-15 21.52.04.png

For example, the screenshot above shows that for Phenix-Arizona, NO2 and O3 pollution levels are more significant than CO and S2 pollution.

Pollution by city

The next step was to compare pollution levels across main US cities.

Screenshot 2019-01-15 21.53.34.png

I chose Boston,Chicago,Houston,Los Angelos, New York,Phoenix and San Francisco for comparison. The graph of box-plots above shows O3 pollution levels. the box-plots demonstrate the fact the warmer cities have higher levels of ozone pollution: Phoenix ranking first and Chicago ranking last.

Least & Most Polluted Cities

Screenshot 2019-01-11 14.44.54.png

I have explored the top 10 polluted and east polluted cities per chemical. The Box-plots above for CO pollution show that major cities such as Los Angelos and Denver consistently rank in the top 10 most polluted cities.

Evolution of pollution levels

Has pollution been increasing or decreasing over time? It is no secret that governments and municipalities has been taking measures to reduce air pollution. Can this be confirmed by modeling pollution levels from 200 to 2010? To answer this question, I have generated plots that the evolution of air quality over the years. The plots show that there is a decreasing trend for most cities in the level of all pollutants. An example would be this plot of NO2 pollution in Detroit approximated with a linear trend.

Screenshot 2019-01-11 14.56.24.png

About Author

karim El Zaatari

Data Scientist and mechanical engineering graduate with a demonstrated record of leadership & problem solving. My data science projects span over various topics including air pollution, carpooling,house pricing and machine learning in horse racing.
View all posts by karim El Zaatari >

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans 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 boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis 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 seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI