Thematic Mapping Techniques

In this workshop we are going to explore various thematic mapping techniques. We will be using QGIS and Mapbox Studio to do this. By the end of it we will have created 5 different maps, all using the same data source.

The data that we’re using is about the greenspaces in Greater London. We have processed OS Open Greenspacearrow-up-right and created a centre point for each greenspace. We are also using some data from Boundary-Linearrow-up-right and OS VectorMap Districtarrow-up-right.

Let’s get started…

QGIS

All the data for this workshop can be downloaded herearrow-up-right. Make sure it is downloaded onto your machine:

  1. Open QGIS

  2. First, we’re going to add in some contextual layers.

Add these 3 shapefiles (the files ending in .shp) from the ‘Data’ folder:

  • ‘Thames.shp’

  • ‘London-Boroughs.shp’

  • ‘London-outline.shp’

You can do this by dragging & dropping them into your QGIS window or by going to Layer in the top ribbon of QGIS > Add Layer > Add Vector Layer and browsing to the files on your machine.

  1. Re-order them in the ‘Layers Panel’ like this:

QGIS Layers Panel
Layers panel
  1. Now we’re going to remove the fill from the Borough polygons.

Open the ‘Layer Properties’ panel by double-clicking on the layer ‘London-Boroughs’.

Go to the Symbology tab on the left, then click ‘Simple fill’ and change the ‘Fill style’ to ‘No Brush’, like this:

Layer Properties - remove fill
Layer properties - Remove fill

Click ‘OK

  1. Now style the Thames polygon with a light blue fill and remove the outline:

Layer properties - Style Thames polygon
Layer properties - Style Thames polygon
  1. Next, style the ‘London-outline’ to make it black with a width of 0.8mm.

Layer properties - London outline
Layer properties - London outline

You should have your contextual map ready now and it should look something like this:

map of London borough outlines based on previous layer property decisions
London borough outlines
  1. OK, now we’re going to add in our data about the greenspaces in London.

From the ‘Data’ folder, add ‘greenspace-within-london.shp’ to your map and make sure it’s at the top of the ‘Layers Panel’.

The points will be given a default style and will look something like this:

Point data for Greenspaces in London
London greenspace (point data)

It isn’t very easy to make sense of this data so we’re going to style it to help improve the depiction.

  1. Double-click on the layer to open up the ‘Layer Properties’ panel.

Then click on the ‘Color’ to open the ‘Select color’ panel.

Within this panel, change the colour value (the ‘HTML notation’) to #7dc579 and reduce the ‘Opacity’ to 50%:

Select Colour dialogue box in QGIS
Select color

Click ‘OK’ and then adjust the settings in the ‘Layer Properties’ panel to look like this:

Symbology panel in Layer Properties with Simple Marker, Size 1.4, stroke style No Pen and blending mode by feature set to Multiple
Layer properties - London greenspace (point data)

The ‘Multiply’ blend mode means that overlapping features will appear darker on the map, giving us a better idea of density. (You can read more about blend modes herearrow-up-right.)

With a couple of simple colour techniques we have created a nice dot density map which shows ALL the data and gives us a good picture of the density and distribution of greenspaces across Greater London.

Your map should look something like this:

Dot density map of London greenspace
Dot density map of London greenspace

Next, we’re going to explore some options for aggregating the data, and we’ll start with a proportional symbol map.

Before we do this, turn off the ‘greenspace-within-london’ layer by unchecking the box next to it in the ‘Layers Panel’.

  1. For this map we need to do some geospatial processing. We’re going to count (or bin) the greenspace points into the London Borough boundaries.

From the top menu click ‘Processing’ then ‘Toolbox’:

Location of the Processing toolbox in QGIS
Processing toolbox

This should open up the ‘Processing Toolbox’ along the right-hand side of your QGIS window.

  1. In the ‘Processing Toolbox’ search for count points.

Under ‘Vector analysis’ you should see a tool called ‘Count points in polygon’ - double-click it to open the settings panel.

Finding the Count points in polygon tool
Count points in polygon
  1. Change the settings so they look like this (you can choose to save to file if you want) and then click ‘Run’:

Count points in polygon dialogue box
Count points in polygon settings

The processing should only take a few seconds, and then a new layer called ‘Count’ will appear in your ‘Layers Panel’:

New Count layer in the Layers panel
Count - Layers panel

If for some reason this doesn’t work, you can use ‘Boroughs-with-counts.shp’ from the ‘Backup Data’ folder.

  1. OK, now we need to style this layer to create our proportional symbols (circles in this instance).

Double-click the layer to open up the ‘Layer Properties’ panel and under the ‘Style’ tab, select ‘Graduated’.

Next, choose ‘NUMPOINTS’ as the column and click on the colour swatch next to ‘Symbol’

Symbology styling as Graduated by NUMPONTS
NUMPOINTS -> Graduated
  1. In the ‘Symbol selector’ panel change the ‘Symbol layer type’ from ‘Simple fill’ to ‘Centroid fill’:

Symbol setting for Centroid Fill
Symbol settings

Now click on ‘Simple marker’ to expand the style options.

Next, click on the ‘Data defined override’ button next to ‘Size’ (see image below) and click ‘Edit…’:

Data defined override’ button next to ‘Size’ and click ‘Edit…'
  1. We’re now going to write a short expression to size the circles based on their value - we need to divide the values in order for the sizes to be correct for our scale of map.

In the ‘Expression string builder’ add in the following expression:

"NUMPOINTS" / 17 ← you can copy & paste this if you want to

The number 17 here is arbitrary really and may need to be changed dependent on the scale of your map and size of your monitor.

Expression String Builder dialogue window
Expression string builder

Click ‘OK’ to return to the ‘Layer Properties’ panel.

  1. Now, adjust the colour ramp to a ramp of your choosing (a single colour, light to dark colour ramp works nicely).

Then click ‘Classify’

Layer properties - Count - Symbology
Layer properties - Count - Symbology

By default, this adds in 5 classes using the ‘Equal Interval’ algorithm (you can read more about the different options herearrow-up-right).

Your proportional symbol map should look like this:

Proportional symbol map of London greenspace
Proportional symbol map of London greenspace

Next we’re going to look at creating a choropleth map and for this we are going to use the same data but change the styling.

First we need to run an extra bit of analysis on the data. You will often hear cartographers discussing the problems of mapping totals using choropleth maps (read more here).

Without normalising our data to a consistent denominator the map is not very useful and we can't make any sensible interpretations of the information.

We are going to normalise our greenspace data against the size of each Borough. We will be mapping the amount of greenspaces per km2 in each Borough rather than the total number of greenspaces per Borough. This takes into account the fact that they’re all different shapes and sizes and makes comparison fairer across the whole map.

  1. OK, so we need to add a new attribute to our data.

In the ‘Layers Panel’ right-click on the ‘Count’ layer and then click ‘Open Attribute Table’:

Open attribute table for Count Layer
Open attribute table
  1. Click on the little yellow pencil button to start editing then click on the abacus button to ‘open field calculator’:

Start editing - Open field calculator
Start editing - Open field calculator
  1. Now we’re going to create a new field.

Type in perkm2 as the ‘Output field name’ and then add the in this expression:

"NUMPOINTS" / ( $area / 1000000 ) 🡨 you can copy & paste this if you want to

We’re working in British National Grid (ESPG:27700) so our map units are meters. This calculation converts our values to kilometre squared.

Count - Field calculator
Count - Field calculator

Click ‘OK’

  1. Click on the little yellow pencil button again to stop editing and then click ‘Save’.

Saving Edits
Save edits

We now have a new attribute field called perkm2 which contains a number for every Borough which represents the number of greenspaces per km2.

Close the attribute table and now we’re going to style our choropleth...

  1. In the ‘Layers Panel’, double-click on the ‘Count’ layer to open up the ‘Layers Properties’ panel.

Click on the little symbol next next to ‘Symbol in order to open up the ‘Symbol selector’:

Symbol selector dialogue
Symbol selector
  1. In this panel, change the ‘Symbol layer type’ from ‘Centroid fill’ to ‘Simple fill’:

Symbol Settings - Simple fill
Simple fill

Click ‘OK’

  1. In the ‘Layer Properties’ panel. Change the ‘Column’ to perkm2 and click ‘Classify’

Layer properties - Count - Symbology
Layer properties - Count - Symbology

Feel free to experiment with the different classification algorithms:

Classification algorithms
Classification algorithms

Click ‘OK’ and you have a choropleth map which should look something like this:

Choropleth map of London greenspace
Choropleth map of London greenspace

Great! We’ve now made 3 different maps, and visualised the same data source in 3 different ways!

So far we’ve been using the London Borough boundaries and these geometries are irregular sizes and shapes.

Next we’re going to look at using a regular grid. We’re going to use hexagons to create a hexbin map. Read thisarrow-up-right for more information about the benefits of using Hexagons over other tessellating shapes such as squares.

  1. We are going to use a QGIS Plugin called ‘MMQGIS’ to generate our hexagon grid. If it doesn’t appear in your top menu then you will need to install it by clicking ‘Plugins’ then ‘Manage and Install Plugins…’

Search for ‘MMQGIS’ and click ‘Install plugin’

Plugins - Manage and install plugins
Manage and install plugins
  1. Once the plugin has been installed, in the top menu click ‘MMQGIS’ then ‘Create Grid Layer’ to open up the ‘Grid’ panel:

MMQGIS - Create - Create Grid Layer
Create Grid Layer

In the ‘Grid’ panel, choose Hexagons as the ‘Shape Type’ and change the ‘Y Spacing’ to 2000 (this will give us hexagons that are 2km in height). Choose a location to save your new shapefile (…) and click ‘Apply’:

Grid dialogue box
Grid settings

You should now have a new layer in your ‘Layers Panel’ and a hexagon grid covering the extent of your map window.

If for some reason this doesn’t work, you can use ‘hexagon-grid.shp’ from the ‘Backup Data’ folder.

  1. Now that we have a grid, we need to count (or bin) our greenspace points into each grid cell. To do this, we’re going to go back into the ‘Processing Toolbox’ and use the ‘count points in polygon’ tool again:

Processing Toolbox - Count points in polygon tool
Count points in polygon

In the settings panel, select your hexagon grid layer as the ‘Polygons’, ‘greenspace-within-london’ as the ‘Points’ and make sure the ‘Count field name’ is NUMPOINTS.

Count points in polygon settings
Count points in polygon settings

Click ‘Run’. This will add a new layer into your ‘Layers Panel’

If for some reason this doesn’t work, you can use the ‘hex-with-counts.shp’ from the ‘BackupData’ folder.

  1. Before styling our grid, we’re going to add a filter on it so we only see the cells that contain data. Double-click the newly created layer to open up the ‘Layer Properties’ panel then switch to the ‘Source’ tab and click ‘Query Builder’:

Layer properties - Count - Source dialogue
Layer properties - Count - Source
  1. Add the expression:

"NUMPOINTS" != 0 🡨 You can copy and paste this if you want

Query builder dialogue
Query builder

Click ‘OK’

  1. Now we’re going to style our hexagon grid. Switch back to the ‘Style’ tab.

Change the style settings so they look like this:

Layer properties - Count - Symbology
Layer properties - Count - Symbology

To change the colours of each category, right click on the colour swatch and go to ‘Change Colour’. Use the colour hex codes in the ‘HTML notation’ box as follows:

#FCE1A4, #FABF7B, #F08F6E, #E05C5C, #D12959, #AB1866, #6E005F

These colours are from our GeoDataViz Toolkitarrow-up-right.

Change colour
Change colour

Please feel free to choose a different colour palette.

When you’re happy, click ‘OK’.

Your map should look something like this:

Hexbin map of London greenspace
Hexbin map of London greenspace

So far, we have explored 4 different mapping techniques within a GIS. If we were creating a finished map, then we would probably add some other features. These may include a title, description, legend, labels/annotations and possibly even a scale bar or locator map.

  1. Have a go at creating a full layout! Go to ‘Project’ and ‘New Print Layout’. Give your layout a name and click ‘OK’.

Project - New Print Layout
Print layout
  1. Add a map, legend and text to your layout

Adding Items in the Layout
Add item

You may need to edit each item using the ‘Item Properties’ panel on the right of your screen. This may mean changing the ‘scale’ of your map Item so it fits on the page (Try 250000). You can also use the ‘Interactively Edit Map Extent tool’ so you can move your map around and zoom in/out.

Item Properties - Scale
Item properties - Scale

For your legend, you’ll likely want to turn off ‘Auto Update’ and use the Minus button to remove unwanted legend items.

Item properties - Legend
Item properties - Legend

Your layout might end up looking something like this:

Complete hexbin map of London greenspace
Complete hexbin map of London greenspace

Now we’re going to look at Mapbox Studio and create a web map that will be mobile friendly by default. We’re going to take our hexbin map a step further and explore the z-axis - adding a 3rd dimension to our data.

Mapbox Studio

  1. In a web browser, preferably Google Chrome, go to studio.mapbox.comarrow-up-right.

If you have an account, login. If you don’t have an account, you can create one for free – it doesn't take long.

  1. Once you’re in Studio, click on ‘Tilesets’ in the righthand menu, under ‘Resources’.

Resources - Tilesets
Resources - Tilesets
  1. Click on ‘New Tileset’

New tileset
New tileset
  1. Click ‘Select a file’, then browse to the ‘Data’ folder and select ‘hex-with-counts.geojson’:

Select hex-with-counts.geojson
Select hex-with-counts.geojson

Click ‘Confirm’.

It may take a few minutes to upload the new data (but it will be worth it, honest).

When our new tileset has successfully uploaded it will appear at the top of our Tileset list.

  1. Now we’re going to create a new map. Click on the ‘Styles’ tab on the right-hand menu and then click ‘New style’

  2. Select ‘Monochrome’ and then ‘Dark’. The click ‘Customize Monochrome’

Choose a template
Choose a template

This will load up the map interface. Pan around and zoom in to London.

Now we’re going to load our hexagon grid into this map.

  1. Click on the ‘+’ (Add New Layer) button in the top-left.

Add new layer
Add new layer
  1. Click on ‘Custom Layer’. A new panel then should open up just to the right.

Custom Layer
Custom layer
  1. Under ‘Source’, click on ‘None Selected’ and then select your ‘hex-with-counts’ data you just added.

Source dialogue box
Source

You should now have something that looks like this:

Mapbox hex-with-counts
Mapbox hex-with-counts
  1. In the editing panel, change the ‘Type’ to ‘Fill extrusion’

Type - Fill extrusion
Type - Fill extrusion
  1. Our new layer should now appear in the layer panel on the left. Click on the 6 little dots next to the layer.

The map view will now change to be tilted. The data is given a default black fill - so now we’re going to style it.

Tilted black contextual map
Tilted black contextual map
  1. Click on ‘Colour’ and then ‘Style across data range’ and then ‘Num #’

Setting the style across data range
Style across data range
  1. Check there is a number 1 in the ‘Num’ box, change the ‘HEX’ to #ffffff and then click ‘Done’

Colour settings
Colour settings
  1. Next, select ‘edit’ on the ‘num 90’ box. Repeat stage 4, checking there is a number 90 in the ‘Num’ box and this time change the ‘HEX’ to #009991 and click ‘Done’. Your setting and map should look like this:

Colour settings
Colour settings
Hexbin tilted map of London greenspace
Hexbin tilted map of London greenspace

15. Next click on ‘Height’ then select ‘Style across data range’ and then ‘num #’.

Height - Style across data range
Height - Style across data range
  1. Like you did before, ensure there is a number 1 in the ‘num’ field and change the ‘Fill height’ to 100. The click Done.

Height - Style across data range
Height settings
  1. Click ‘Edit’ for ‘num 90’ and change the ‘Fill height’ to 10000. Click ‘Done’

Your settings and map should now look like this:

3D hexbin map of London greenspace
3D hexbin map of London greenspace
  1. Click on ‘Opacity’ and change the ‘Fill Opacity’ to 0.65. This allows you to see some of the underlying data. Feel free to have a play with the opacity.

Opacity settings
Opacity

You can use your right mouse button to adjust the pitch and bearing of your map. It should look something like this:

3d hexbin map of London greenspace with opacity
3d hexbin map of London greenspace with opacity

Feel free to play around with the other layers in the map (roads, water, labels etc.) - style it to suite your own needs or preferences.

It is also good practice to move your new thematic layer below the map labels. You can do this by dragging and dropping it in the left-hand panel.

  1. When you’re happy with your map, you’re ready to publish it!

Click on the ‘Publish…’ button in the top righthand corner of your screen.

On the next screen, click ‘Publish’ again. You should get a pop up saying your Style has been successful published. Click ‘OK’.

  1. Your map is now hosted on your Mapbox account and you have a number of options for how you can use it; from simply sharing it, viewing it in a GIS or developing it further using one of Mapbox’s libraries.

For our final step we’re going to check that our map looks good on a mobile device. Mapbox have an app that makes this easy for us. If you have an Android or iOS device then install the Mapbox Studio Preview app from the relevant store.

Using this app you can sign-in with your account details and view your styles on your device.

Mapbox hexbin map of London greenspace on mobile device
Mapbox hexbin map of London greenspace on mobile device

Last updated

Was this helpful?