Skip to main content

Geospatial Python

Author

Jean Golding Institute

About this course

Most health data has a location attached: where a patient lives, where a GP surgery is, where a case of a disease was reported. This course introduces working with maps and location data in Python, using one of the most famous stories in public health.

In 1854, cholera killed hundreds of people within days in Soho, London. Most doctors believed it spread through “bad air”, but the physician John Snow thought it spread through water. He mapped where people had died, and showed that the deaths clustered around one water pump, on Broad Street.

In this course you will recreate his analysis with the geopandas library. Along the way you will learn the ideas behind geospatial data science: vector and raster data, coordinate reference systems, spatial joins and catchment areas. We finish by asking what a map like Snow’s can and cannot tell us.

The course takes three hours, including a break. Each section starts with the ideas, then we write the code together in Google Colab, and then you try a short exercise on your own. The notes are written so you can also work through the course on your own.

Prerequisites

  • Basic Python: variables, lists, functions and importing packages. Our Introduction to Python course covers this.
  • Some experience of pandas helps, but is not required: we explain the pandas we use.
  • No experience of maps or geospatial data is needed.
  • A Google account, to use Google Colab. Nothing needs to be installed on your computer.

Learning outcomes

By the end of this course, you will be able to:

  1. Load location data into a GeoDataFrame, and describe how it differs from a pandas DataFrame.
  2. Explain what a coordinate reference system (CRS) is, and check and change the CRS of a dataset.
  3. Make a static map with a background map, and an interactive map.
  4. Join datasets by location, for example to find the nearest water pump to each address.
  5. Divide an area into catchments around points, and summarise data within each one.
  6. Describe what a map can and cannot tell us, using Snow’s map as an example.

Course outline

Section Topic Time
Introduction and the story 25 min
1 Location data 35 min
Break 10 min
2 Making maps 25 min
3 The nearest pump 30 min
4 Pump catchments 25 min
5 What the map cannot tell us 20 min
Summary 10 min

References & Citations

The data comes from Robin Wilson’s digitised version of John Snow’s map. His website lists teaching as one of its uses.

  • Wilson, R. John Snow Cholera Data. johnsnow.rtwilson.com
  • Snow, J. (1855). On the Mode of Communication of Cholera, 2nd edition. London: John Churchill.