Leveraging data from Toronto’s Open Data Portal, I’ve prepared a brief introduction to simple plotting of vector data using Python. This article won’t teach you how to recreate some of the stellar interactive dashboards we’ve seen floating around the web (such as my favourite by John Hopkins University). Rather, this article will provide a beginner’s introduction to using the GeoPandas library in Python, and producing two kinds of maps: a proportional symbol and choropleth map.

(Disclaimer: As a former geography student, I feel the need to address that these maps will lack certain cartographic conventions such as a north arrow and scale-bar. The aim for this article is to instruct on how to crate maps in GeoPandas; instructing how to hack these features into a GeoPandas figure is not my perogative).


I. What is GeoPandas?

GeoPandas is an open source python project aimed at making geospatial data easier to work with. It’s essentially an extension of the Pandas library for data analysis, and provides a user-friendly interface for manipulating and plotting geospatial data (source: https://geopandas.org/).

While stronger and more complex GIS software exists out there, GeoPandas is openly accessible to anyone with a basic understanding of Python and achieve basic visualization tasks.

II. The Data

The geospatial data can be found here in the city of Toronto’s Open Data Portal. Under the Download Data dropdown, select to download the data as a ‘Shapefile’. Upon downloading, you’ll find six files, all of which are important, however you’ll only interact with the .shp file in Python. This is shapefile contains the geographic coordinates of the 140 Toronto neighbourhoods. The neighbourhood boundaries are represented as polygons, defined by latitude and longitude coordinates. This is an example of **vector **data — which uses points and line segments to identify locations on the earth. We’ll be using this dataset to create our basemap.

The COVID-19 data can be downloaded from Toronto’s interactive data dashboard that was released to the public earlier this year. The data we’ll be visualizing reflects the COVID-19 situation in all 140 Toronto neighbourhoods on June 26th, 2020. For each neighbourhood, we are provided with two data points:

  1. Case Counts: the total number of COVID-19 cases (cases which have resulted in death or recovery are included in this count)

2.** Incidence Rate per 100,000 people:** the number of new cases identified for every 100, 000 people

How to Download the COVID-19 Data:

  1. Follow this link
  2. In the interactive data dashboard, navigate to ‘COVID-19 Toronto Neighbourhood Maps’
  3. Select ‘Download Excel Data’
  4. In the excel document, navigate to the tab ‘Case Counts by neighbourhoods’ and export the spreadsheet as a .csv file

Once everything is downloaded, we can begin opening these files in Python. I’ve created a Jupyter Notebook for this tutorial, which you can view in its entirety here.

#geospatial-data #toronto #geopandas #python #mapping #programming

Mapping COVID-19 Infections in Toronto with Python
4.45 GEEK