Labs

  1. Lab 1: Tools (Sep 2, 2020)
  2. Lab 2: Tidy Data (Sep 9, 2020)
  3. Lab 3: Data Engineering (Sep 171, 2020)
  4. Lab 4: Geo-Visualisation (Sep 23, 2020)
  5. Lab 5: Networks and Spatial Weights (Sep 30, 2020)
  6. Lab 6: Linear Regression (Oct 7, 2020)
  7. Lab 7: Clustering (Oct 14, 2020)
  8. Lab 8: Points (Oct 21, 2020)

Note: The labs will be updated by at least the previous Friday for every week before it begins.




Lab 1 - Tools

IMPORTANT This is a supplementary notebook that covers many basics of the tools we will use in the course but does not explain anything directly related to Urban Data Science.

Students are encouraged to read it once before getting started with the other notebooks and then keep it as a reference throughout the rest of the course. There are some basic Python operations in there that act as a refresher, practice or learning material.

Notebook

Additional materials

If you want to explore further by yourself the contents presented in this tutorial, the following pointers are good places to start:

References

  1. Downey, A. (2012). Think Python - How to Think Like a Computer Scientist. Green Tea Press.



Lab 2 - Tidy Data

Notebook

Data

This session uses the “Census socio-demographics” dataset of Liverpool, United Kingdom in two parts. The dataset for this lab is provided in the zipped lab files above.

  1. Table of LSOA areas in Liverpool with population counts by World region. The table is derived from the CDRC Census data pack.
  2. Collection of socio-demographic characteristics from the 2011 Census for the city of Liverpool.

Additional materials

  • A good extension of this session is (Wickham, 2014). The paper is published under an Open Access license, so it is freely available on the journal’s site, but the author has also made available a public repository with the data and code used in the paper. Keep in mind the paper, and the code that comes with it is based on R, not on Python.
  • [Visualization] Python library seaborn tutorial.
  • [Recommended] (McKinney, 2012): An excellent introduction to Python for data analysis, with plenty of examples and code snippets (Publisher’s page link).
  • NY Times article about the importance of cleaning data.

References

  1. Wickham, H. (2014). Tidy Data. Journal of Statistical Software, 59(10).
  2. McKinney, W. (2012). Python for data analysis: Data wrangling with Pandas, NumPy, and IPython. O’Reilly Media, Inc.



Lab 3 - Data Engineering

Notebook

Data

This session uses two datasets which are provided in the zipped lab files above.

  1. A dataset about wines from different countries, download from Kaggle.
  2. A dataset scraped and collected from Goodreads.



Lab 4 - Geo-Visualisation

Lab 4 homework exercises are embedded within the lab files itself. You have to complete the exercises as you go along understanding the rest of the code. There are two files for this lab, geovis and eda. Submit one or both together as one zip file on Peer when you are done. Since this geocomputational lab is not as straightforward as other python code, a solution set will be provided for questions indicated in the lab after submission ends.

Notebook

Solutions

  • lab-solutions-zip

Data

This session uses multiple datasets which are provided in the zipped lab files above.

  1. A “Census socio-demographics” dataset as well as the Ordnance Survey (OS) Geodata Pack.
  2. An “Index of Multiple Deprivation”" dataset as well as the Ordnance Survey (OS) Geodata Pack.
  3. Additionally, you will need the raster file for the basemap of Liverpool. This has been assembled by Dani Arribas-Bel from the OS VectorMap District (Backdrop Raster), and it is licensed as OpenData.
  4. Simple datasets on heart diseases, titanic and a mystery you can find out for yourself.

Additional materials

  • A good introduction to the geopandas project is provided by Kelsey Jordahl, the project’s founder in this set of slides from a 2015 talk and the companion repository.
  • An additional great resource is this 4h. workshop by Carson Farmer.



Lab 5 - Networks and Spatial Weights

Notebook

Data

This session uses multiple datasets which are all provided in the zipped lab files above.

  1. An “Index of Multiple Deprivation”" dataset used in previous labs.
  2. A Brexit dataset.

This is the dataset of the results of the 2016 referendum vote to leave the EU, at the local authority level. All the necessary data have been assembled for convenience in a single file that contains geographic information about each local authority in England, Wales and Scotland, as well as the vote attributes. The file is in the modern geospatial format GeoPackage, which presents several advantages over the more traditional shapefile (chief among them, the need of a single file instead of several). The file is provided below,

Unzip and add this file to the data folder as well.

The source data used to compile the file linked above include:

  • Electoral Commission data on the EU referendum results ( url)
  • Local Authority District boundaries ( url)

Required before the practical

Watch the section on spatial weights of the SciPy’16 tutorial on Geographic Data Science with PySAL.

[ YouTube - Min 1:02:55 to 1:25:40]

Watch the section on ESDA of the SciPy’16 tutorial on Geographic Data Science with PySAL.

[ YouTube - Min 1:25:40 to 1:49:20] [ Online materials]

Additional materials

  • The “User Guides” in PySAL's documentation are an excellent resource to better get to know the library.



Lab 6 - Linear Regression




Lab 7 - Clustering

Notebook

Extra Practice

Data

This session uses the “AirBnb listing for Inner London - MSOA level” dataset. Go to the Datasets tab to find out more information as well as instructions to download it.

Required before the practical

Watch the section on spatial clustering of the SciPy’16 tutorial on Geographic Data Science with PySAL.

[ YouTube - Min 2:30:00 to 3:02:00]

Additional materials

  • Although a bit more advanced, the documentation for scikit-learn, a world-class Python library for machine learning, is excellent and includes many examples that cover the entire functionality set of the library.



Lab 8 - Points

Notebook

Data

This lab uses a sample of geo-referenced tweets for the city of Liverpool. Go to the Datasets tab and check the Geo-referenced tweets section to find out more information about the data as well as instructions to download it.

Required before the practical

Watch the section on points of the SciPy’16 tutorial on Geographic Data Science with PySAL.

[ YouTube - Min 1:50:00 to 2:30:00]

Additional materials

  • A very good resource for kernel density estimation in Python is provided in this blog post by Jake Vanderplas.
  • The R package spatstat provides extensive functionality to statistically describe and model point patterns. Note that this is in R, not Python.

  1. On Sep 16th 2020, Wednesday, there is no lecture. I think that is because you have an EPA Programme session. ↩︎