Visualizing the Green New Deal with R Shiny

[This article was first published on R – NYC Data Science Academy Blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

New York has pressed on with environmental legislation while the nation dawdles – where and by whom will the impact be felt?

Shiny app | GitHub

As mentioned in my last post, effective and timely legislation will be a key weapon in the battle to keep greenhouse gas emissions at sustainable levels and avoiding an ecological crisis. This will involve both supportive policies for new clean technologies and business models as well as measures to phase out the worst contributors to the problem.

New York City’s Climate Mobilization Act is packed full of the latter, with hints of the former. Overall it is an attempt to keep the city in line with emissions targets set by the Paris International Climate agreement, particularly important for the city given its vulnerability to rising sea levels. Mayor Bill De Blasio’s own Office of Sustainability said “Protecting New Yorkers from climate change is not optional.”. You can read and hear more about the act on the front page of the app.

This visualization and its later iterations have value for any business in the city seeking to understand how they might be affected. Conversely, it also represents a way for energy companies to map possible opportunities. If they can better understand who will have to make significant energy efficiency upgrades as a result of the new laws, they can market products more efficiently.



The visualization is built using ShinyDashboard, with three tabs. The first gives an overview of New York State’s current emissions situation, and some more information on what exactly is specified in the main components of the new act. The press release can be found here. The other two tabs go on to examine two specific bills.

The GoogleVis chart on this page gives indicative numbers for where New York State’s emissions have come from, and where current plans might mean they come from in the future – the data for this comes from the State’s Department of Environmental Conservation. Here I have included fossil fuel combustion in residential, commercial or industrial properties, as well as for electricity, all under the buildings category, while the industry category contains emissions as a result of industrial processes. The fundamental takeaway from this chart is that although progress has been made, if the state is to meet its own emissions reduction targets by 2030 it must do approximately 3 times as much work in 10 fewer years than it did from 1990 – 2015.


The second tab in the app examines the so-called “Dirty Buildings Bill”, which requires buildings over 25,000 square feet to cut emissions by 40% by 2030, and 80% by 2050, by retrofitting new windows and insulation. The questions I really wanted to be able to answer with this tab were which areas, and what types of property, have the most to do when it comes to emissions reductions.

This tab uses building benchmarking data from NYC’s Office of Sustainability. This was relatively easy to clean. Using the filters on the right hand side updates the GoogleVis scatter plot and ggplot histogram, allowing the user to examine distributions of building sizes and emissions. The outliers button is necessary to make the visualization clearer – the dataset is self-reported and there are clearly some errors. Finally, the infobox in the top right hand corner updates as the user filters to show the average annual emissions of the buildings selected.

There is a lot of exploring that can be done with this tab. A few general results are:

  • Offices, data centres, residence halls and hotels rank amongst the biggest greenhouse gas emitters, K-12 schools and distribution centres were surprise entries at the low end of the ranking
  • Manhattan has the highest average building emissions, and the highest average emissions intensity (emissions per square foot), while Brooklyn has the lowest of both of these metrics
  • Newer buildings generally have lower emissions, and more significantly, lower emissions intensities


The final tab in the project analyses a bill (which requires another vote) to convert all school buses to electric within 20 years, part of New York City’s goal to switch all public buses to electric by 2040. Here the aim was to see which boroughs currently suffer from the worst pollution, and hence would benefit most from less exhaust fumes.

There are three layers to the interactive leaflet map. The yellow circles denote the positions of school bus garages, and their radius is proportional to the number of bus routes operating out of that garage. The brown circles similarly denote the positions at which pollutants are measured, their radius again being proportional to the total number of pollutants measured there. The choropleth of the boroughs shows the level of different pollutants associated with exhaust fumes (Carbon Monoxide, Hydrocarbons, Particulate Matter etc.). These can be selected on the right hand side and for some pollutants the type of sample also needs to be chosen.

This tab was harder to build. The data came from two separate sources; school bus information came from NYC Open Data whilst the air quality data came from the Environmental Protection Agency. The two unfortunately used different coordinate projections to locate the garages and pollutant measurements, respectively, so required some pre-processing before the pollutant data could be joined with the shapefiles. The borough shapefiles themselves came from the US Census Bureau.

A couple of conclusions from exploring this page:

  • There are large concentrations of school bus garages in areas of Queens, The Bronx and Brooklyn. Electrifying these will put large strain on the electricity networks in these areas. Effective local flexibility technologies like energy storage may be required to ease the transition.
  • Across the main vehicle pollutants, Queens seems to do the worst and hence has most to gain from more electric cars on the city’s roads

Conclusions and further work

The first conclusion that should be highlighted here is that whilst the Climate Mobilization Act is a step in the right direction, it is still a small step compared to the scale of the challenge. Averting climate breakdown will require many more of these policies – this is the start of New York’s climate change fight and not the end!

The app in its current form can be used to used to identify those areas, and in the case of the buildings data, those property segments that will be most affected by the new legislation. However, this only explores 2 of the 10 bills in the act, in the future I will expand this. My first target will be the bill investigating how to wean the city off fossil fuels. Looking at the data for wind/solar potential in the surrounding area and at sea could be very interesting. I would also like to introduce some way to tie the effects of the bills together, to try to get a concise overall picture of the impact of the package.

The buildings data unfortunately only lists buildings above 50,000 square feet, however as of next year this will be revised down to 25,000 square feet, which would make that data set even more relevant. Additionally, you may notice that Manhattan lacks a number of the pollutant measurement observations – a pollution data set with less geographically coarse measurements would be beneficial if it could be found.

To leave a comment for the author, please follow the link and comment on their blog: R – NYC Data Science Academy Blog. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)