Mapping UK open data with Python

There is a lot of free geographic information about the UK made available by the UK government (Land Registry, ONS, DFT…etc.)  and institutions (Post office, Ordinance Survey, …etc.). This post is about my exploration into making some maps with this data in python. There will (hopefully) be another post about where this data came from and the pre-processing I’ve done. For now, my GitHub page has more information.

Aim:

Make simple plots of all of the transport links around a given area and also make a plot of some more natural locations.

Tools:

Python, main packages being geopandas and matplotlib

Method:

  1. Import the various pieces of source data
  2. Make a large dictionary of GeoDataFrames
    1. Some of the GeoDataFrames are point based, e.g. Land Registry Price Paid Data, or the NSPL list of postcodes
    2. Some are lines, e.g. the UK road network
    3. Others polygons, e.g. the National Park boundaries
  3. Choose a number of key locations and clip to a 5km2 boundary around these locations
  4. Use matplotlib to plot different layers and save as a picture

Outputs

The outputs aren’t quite as pretty as I’d have liked. But they are also better than I expected. I made two sets of maps based on the input data

1 – Transport Links

This map has

  • UK road network, from unclassified roads to motorways, as progressively thicker black lines
  • Train lines as dashed lines
  • Domestic ferry lines as blue lines
  • Urban region polygons as gray polygons
  • Postcode centroids as transparrent blue dots
  • Train stations (not the tube) green stars
  • Bus Stops as red stars
  • Motorway junctions as gray pentagons

Below we have the transport features map with St Paul’s in the centre. you can clearly see the rail (not the tube, I haven’t found .shp files for this yet) and road network. And you can see the more densely populated areas in blue as the postcodes pile up.

For these maps I wasn’t aiming at anything useful. I just wanted to find out how to map in python and the test if my data looks ok.

2 – Natural Features

This isn’t the best description but it’ll do. this map has

  • The sea (and border as I couldn’t work out how to do this) in aqua
  • Roads (not natural, but they help me recognise the locations) in a very faint gray
  • Urban green space (e.g. parks) in green
  • Woodland in brown
  • Rivers in blue
  • Lakes in a circle hashed blue
  • Foreshore regions in a light blue
  • National Parks hashed by red dots

From looking at some of the graphs the lakes data doesn’t look 100% correct. These are from OS Strategi which was discontinued in 2016.

Below we there is the Natural Features around Hawkshead. You can clearly see the various becks and their tributaries. But it looks to me like Esthwaite Water & Tarn Hows aren’t quite in the right place but not too far off. The whole area has the red dots confirming it’s in the Lake District and you can see the various woodlands around the village. From looking through a few of the maps it looks like the whole Strategi data is slight offset to the other sources. This might be my fault

I’ve put some more of the output maps in the gallery below including some of 2020 road accidents and 2020-2021 property sale prices (no legend).

Leave a Comment

Your email address will not be published.