May 15, 2017 | Xing Brew
Open Data Toronto

Open government data is a tremendous resource that is still largely untapped. Governments collect a broad range of data in various forms and a growing number of them are making the data publicly available. Open data is of great value for governments and people by facilitating transparency and democratic control, participation, innovation, improved effectiveness and efficiency of public services, and new knowledge derived from combining and analyzing data from various sources.

Toronto, like many cities around the world, is making more and more of the data it collects available to the public. The City’s Data Catalogue includes datasets on topics including water quality, public safety, all the festival and events happening in the city, the location of long-term care homes, and places of worship. The files comes in various formats (XLS, CSV, Shapefiles, etc.) and can be accessed and downloaded very easily from toronto.ca/open.

Although some of the data may be interesting to examine in its raw format, the information really comes to life when analyzed and/or visualized using a program like R. What’s more, we can use R to combine various datasets to create mashups to gain insights and tell stories that the data providers would never have anticipated.

I was interested in seeing where all the homeless shelters are situated across the city of Toronto. So, I downloaded a dataset containing the location of the shelters within the City of Toronto in the form of geometric coordinates and collected a bit more information about each shelter (address, phone number, type of individuals served, and number of beds) from the City’s Shelter, Support and Housing Administration website, which I saved as a CSV file.

Using the Leaflet package in R and a simple line of code, I got a map of Toronto to which I could easily add the shelter locations to. I could also change the marker size to reflect the number of beds in the shelter and the colour of the markers to show the types of individuals served at each shelter. Finally, I added pop-ups to display a shelter’s name, phone number, and precise capacity when its marker is clicked.

Here is the end product:


And here is all the code that was needed to create this map.

This is just one example of many, many different types of maps and visualizations that can be created with open government data using R. Here are some good resources about open data:

Back to Blogs →