3D mapping and bathymetry styling with QGIS 2.18

This is a guest blog from Liam Mason, a spatial analyst with Marine Scotland.  Some of his other data visualisations can be seen on his @marinemaps Twitter account or the Marine Scotland Maps portal maps.marine.gov.scot


[Edit: the tutorial was modified to use the GDAL-based DEM (Terrain Analysis) tools instead of Raster Terrain Analysis]

I love mapping bathymetric data in 3D. It’s almost magical, the ability to draw back the veil of the sea and reveal the mysterious landscapes below.

Yet, it’s remarkably simple to do using QGIS 2.8 or higher.

3D bathymetry map of inner Firth of Forth.
Bathymetry of inner Forth made using QGIS 2.8 and qgis2threejs

The Plugins

This tutorial uses one core and two additional plugins, which can be installed using Plugins > Manage and Install Plugins…

Screenshot of showing Plugins option in menu 

Firstly, ensure that GdalTools is installed and activated.

Screenshot of QGIS showing GDAL tools

Secondly, search for qgis2threejs, and install.

Screenshot of QGIS plugins showing qgis2threejs

Thirdly, search for and install quickmapservices which will give you access to a variety of basemaps.

Screenshot of QGIS plugins showing QuickMapServices

Both of the latter plugins are available in the Web menu.

Lastly, you can further expand the basemaps available in QuickMapServices via Web > QuickMapServices > Settings > More services > Get contributed pack

Screenshot of QuickMapServices 'get contributed pack' option

Other software

This tutorial involves picking colours from the basemap.

The Windows version of QGIS has an  integrated color picker tool, but for those of you using Mac OSX, Just Color Picker is an alternative (and free) colour picker tool available on the App store.

Just Color Picker on App store
Just Color Picker on App store

The data

We’ll need a digital elevation model (DEM) which contains both bathymetric and terrestrial elevation data otherwise either the land or sea will be flat.

This tutorial uses the GEBCO 2014 gridded data:

https://www.gebco.net/data_and_products/gridded_bathymetry_data/ 

Although the data is quite coarse at 30 arcseconds resolution, it’s suitable for 3D mapping at country-wide scale.

On GEBCO website, holding down the Shift key, click the left mouse button and drag to select the area for download.Screenshot of GEBCO website showing selection map

Click to expand GEBCO_2014 Grid (30 arc-second interval). Tick INT16 GeoTIFF (data)

Screenshot of GEBCO website

Scroll down and click  Add data to basket.  When the text on this button greys out, click View basket.

On the next site, select Check out your request.

Screenshot of BODC website

If you don’t already have an account with BODC, you’ll need to register. Don’t worry though, it’s free and you won’t get spammed with emails.

Once registered, log in using your email and password.  If you don’t want to supply a reason or funding information, simply type any character eg a space and Login to proceed.

Screenshot of BODC website

Once logged in, you can Download the data.

Screenshot of BODC website

Alternatively if you only want to map the undersea terrain, EMODnet (http://www.emodnet-bathymetry.eu/data-products) is a fantastic source of open bathymetry data, but you may need to merge the rasters.

(For the Firth of Forth image, I combined a licensed bathymetry product from OceanWise, with Ordnance Survey’s Panorama terrestrial product)

The method

Loading and configuration

Firstly, use the Add raster button to load the GEBCO DEM.Add Raster data button

Now we’ll drape a basemap imagery layer via QuickMapServices > ArcGIS Online > ArcGIS Online Imagery (options may vary depending on version of Contributed Pack)

[I had to use ESRI > ESRI Satellite. Ed.]

Screenshot of ArcGIS online imagery in QuickMapServices menu

Set the Project Properties to EPSG:3857. (Pseudo/Spherical/Web Mercator, whatever you want to call it!)

Screenshot of QGIS project properties in menu

Screenshot of project properties showing EPSG 3857 selected

This changes the project’s units to metres, which makes it easier to use the 3D plugin.

EPSG:3857 is the native projection for the basemap.  Other metre-based projections can be used to reduce distortion, but  other projections  may reduce performance if transforming / projecting on-the-fly.

Creating the 3D viewer

Zoom and pan to the area of interest.

Screenshot of ESRI world imagery

Load the qgis2threejs 3D plugin via Web > Qgis2threejs > Qgis2threejs

Screenshot of qgis2threejs in menu

Change the template file to 3Dviewer.html (this reduces some of the tools in the resulting interactive map)

Screenshot of template file in qgis2threejs

In World settings, enter an appropriate vertical exaggeration.  In this tutorial, we want to exaggerate large undersea features, so we’ll use 40, but normally we’d use a smaller value.

Screenshot of vertical exaggeration settings in qgis2threejs

(Note: if the project’s horizontal units are degrees, we’d need to use very small decimal values. That’s why we changed the project’s properties)

In DEM settings, ensure the GEBCO data is selected as the DEM Layer.

For the highest resolution output, slide the Resampling slider to the right and set the Resolution to 400% (these settings may need to adjusted depending on your computer’s performance).

Optionally, untick Build sides.

Screenshot of qgis2threejs DEM settings

Finally, set an Output HTML file path and Run to start

Screenshot of qgis2threejs file path and run options

It’ll take a moment to process, but the output HTML should load in your browser automatically. (In Internet Explorer 11, you may need to okay an error pop-up)

3D model of North Atlantic

Voila! You have an interactive 3D model of the north Atlantic. Neat, huh?

Improving the bathymetry style (colours)

The imagery basemap in this tutorial includes bathymetric shading at smaller scales.  We have more control if we create our own custom bathymetry style though. (The same tricks can be applied with for 2D mapping too)

Firstly, add another copy of the DEM using Add raster button, ensuring it’s positioned above the basemap in the table of contents.Add raster button

Right-click the copy layer and select Properties

Screenshot of layer properties in menu

In Style, select Singleband pseudocolor  as Render Type.

Set the Max to 0 and the Min to approximately the deepest point in the visible extent. We’ll use -2000 as an example.

Screenshot of raster style properties

Use the Add values manually button, double click on the value field for the resulting entry and enter -20.

Using a colour dropper tool, change the three colours to the lightest sea colour on the basemap. (If using high resolution aerial imagery, try to avoid sandy beaches)

Screenshot of raster classification values

Screenshot of colour options

Now adjust the colour for the deepest value (-2000 in example) by moving the V slider (value) to the left which will darken the colour. 

Screenshot of colour options

For the shallowest depth (0), adjust the opacity to 0%. Values shallower than 20m now fade to transparent.

Screenshot of colour options

We now have a bathymetry colour scheme that works stylistically with the basemap.

We can experiment by changing the depth values. The shallower depth works best between -10 and -30.  Changing the deeper value from -2000 to -1000 for example, the darker colour moves shallower.

Screenshot of ESRI World Imagery with custom bathymetry colours (no shading or texture)

Improving the bathymetry style (shading and texture)

Next we’ll improve the shading and texture.

Select Raster > Analysis > DEM (Terrain Models)…

Screenshot showing DEM tools

Select DEM as Input file

Set an output file.

Ensure mode is Hillshade.

The example data stores height data in metres but uses degrees as horizontal units, so the Scale should be 111120.  (See gdaldem guidance )

Tick Load into canvas when finished

Run tool using OK

Screenshot of DEM tools

When the hillshade layer loads, open the properties.  Experiment with the Style settings for different effects.

I tend to pick Soft light for blending mode, with increased brightness and increased contrast.

The default min and max values are rarely suitable, I used 125 and 255 respectively.  (HT to Ireland QGIS User Group)  

Screenshot of raster layer properties

The final improvement is to add a slope analysis via Raster > Analysis > DEM (Terrain Models)…

Screenshot showing DEM tools

Similar prodecure to hillshade, but select Slope for Mode.

Again, Scale should be 111120 for tutorial data. Same guidance applies for slope as per hillshade

Screenshot of DEM tools

Once loaded, adjust the Style Properties of the slope layer so Color gradient is White to black.

Like the hillshade analysis, experiment with Min/Max, blending modes, brightness, contrast, and transparency.

Screenshot of properties

Screenshot of transparency

The settings  in screentshots above are used in the example below.

ESRI World Imagery with custom bathymetry applied

We now have a custom bathymetry style with improved shading and texture. 

Finally, repeat the QGIS2threejs steps to create a 3D model using our custom bathymetric style.

3D model of North Atlantic using ESRI World Imagery and custom bathymetry

Ta-da!  Now have some fun and experiment with different basemaps!  

3D model of North Atlantic using OSM Mapnik and custom bathymetry
3D map using OSM Mapnik render

 

 

Creating Cartograms using QGIS 2.18

Cartograms

First a confession, I don’t like cartograms, at least not the kind where complex boundaries are warped sometimes beyond recognition. However they do have their place and where there aren’t the extremes in the data a cartogram can be a great data visualisation. It is outliers or extreme values that cause the maps to be distorted beyond usable recognition, and therefore look bad (see below).Cartogram PaullHennig2016WorldMap.OAha.CC-BY-4.0

By John Paull and Benjamin Hennig (http://orgprints.org/30187/) [CC BY 3.0 (http://creativecommons.org/licenses/by/3.0)], via Wikimedia Commons

Anyway, if your data isn’t going to produce a map like this then you can use the Cartogram plugin in QGIS. This allows you to quickly turn your map into one that removes the misrepresentation of small areas hiding large values.

The Cartogram Plugin

To start creating your Cartogram you will need to add in the Cartogram plugin using the Manage and Install Plugins interface:

Installing QGIS plugins

Search for Cartogram, once installed you should see it in your list of plugins:

Installing the Cartogram Plugin

The Data

We are going to use the London Boroughs for this exercise which we are going to scale by the number of people that voted in the EU Referendum.

The data can be downloaded here in GeoPackage format:

LondonBoroughEURef.gpkg

The Method

The plugin makes this all super simple, just start the plugin by clicking on the Vector menu at the top of the screen then Cartogram and Create Cartogram:

Opening the Cartogram plugin

A very simple interface opens where you select the data you want and the attribute you want to scale it by:

Cartogram plugin options

In this example select the LondonBoroughEURef as the Input layer and then the Votes as the Area field.

Iterations

Before you click OK it asks you how many iterations to perform. The default is 5 and this is about right. After this the difference you get is increasingly marginal, with the difference between 10 and 15 iterations imperceptible in most areas.

Base data for Cartogram of London
Base Data
1 Iteration Cartogram of London
1 Iteration
2 Iteration Cartogram of London
2 Iterations
3 Iteration Cartogram of London
3 Iterations
4 Iteration Cartogram of London
4 Iterations
5 Iteration Cartogram of London
5 Iterations
10 Iteration Cartogram of London
10 Iterations

You might be able to see that there isn’t much difference between the change from 4 to 5 iterations and 5 to 10 iterations. However there is a much bigger wait for creating a 10 iteration cartogram than there is for a 5 iteration one. All these images have been combined here with the darkest being 10 iterations and the lightest the original London Boroughs:

Multi layered Cartogram of London
London Borough Cartograms: Each borough is scaled by the number of votes cast in the EU Referendum of 2016. The darker the line the more iterations run by the Cartogram plugin in QGIS: 0, 1, 2, 3, 4, 5, 10.

IMPORTANT NOTE: Each time you run the Cartogram Plugin it creates a new virtual layer called Cartogram. You will need to save this if you want to do anything with it, or not loose it if you close QGIS without saving.

Final Tips and Tricks

If you want to make a cartogram out of data that has got outliers or extreme values there are few things you can do to prevent the distortion affecting your the usability of the map.

Animation:

We have seen that the plugin will provide you with intermediate steps between the base data and the final number of iterations you choose. By generating a map for each of the intermediate numbers of iterations you can create a series that can be animated. Just use the Save as Image… option from the Project menu to create a .png file for each one:

Save as Image in QGIS Project menu

You can then use your favourite animated GIF maker on the internet (just google it) or put it into any movie maker package you have access to. The result will show people how the areas have changed and explain areas where the warping makes them unrecognisable:

Animated Cartogram of London
Animated GIF of the London Boroughs. The map shows most voters are in the central boroughs except the City of London which has the least.

Tone down the effect

There was a very interesting paper at the GISRUK 2017 conference by Richard Harris, Chris Brunsdon, Martin Charlton and David Manley:

Tackling the Curse of Cartograms: addressing misrepresentation due
to invisibility and to distortion

In it they describe a few ways that will help mitigate the problems of extreme cartograms. However you may need to use a different method from the cartogram plugin to achieve the desired effect.

Creating a statistical dot density map with QGIS

Dot Density maps:

These maps display the density and distribution of a phenomena over a geographic area. The markers, usually a dot or cross, represent the occurrence or an aggregation of occurrences which are then randomly distributed across distinct regions of the map. Colours can be used to represent different classifications to add an extra dimension to the map.

The example above shows votes to remain (red) and leave (blue) the European Union in the London Boroughs. Each dot represents 100 votes and these have been randomly scattered within each borough to represent the density of votes.

The Data

For this exercise we are going to use a geopackage which contains the outlines of the London Boroughs.  The attributes of the boroughs include the number of votes to remain and the votes to leave the EU. You can download the data here:

London Boroughs EU Referendum Results

Contains OS data © Crown copyright and database right (2017)

The Method

Field Calculator

Before we can start generating the dots on the map we need to create a column with a reduced number, as there were too many votes cast to give each one its own dot. To do this we will use the field calculator to create new attribute columns with the numbers of votes each way divided by 100.

  • Right-Click on LondonBoroughEURef in the table of contents and select Open Attribute Table
  • Click on the Open Field Calculator button above the table: 
  • You will need to set up the Field Calculator as follows:

  1. Make sure the Create a new field option is selected and enter the name 100 Leave Votes.
  2. Make sure the Output field type is set to Whole number (interger) and the Output field length can be left at the default 10.
  3. The expression needs to be: “Vote_Leave” / 100 you can user the Fields and Values section to the right to make sure you get the right field names and quote marks, just double click on the field name you want.
  4. Click OK.

Now repeat this process to create a similar column for the remain votes, call the column 100 Remain Votes. The table should now look like this:

Click Save edits  then toggle out of Edit mode 

Random points

 

Now we have the reduced quantities we can use QGIS to randomly assign points across each area.

Select the Random points inside polygons (variable) from the Vector > Research Tools menu.

Fill in the values as follows:

  1. Although we are making a density map we are going to use the Points count Sampling strategy.  This will assign the number of points in the Number field to each polygon.
  2. Choose 100 Leave Votes to be the Number field. Don’t choose Votes_Leave or Votes as you will then be creating a huge number of points in each polygon!
  3. Set a Minimum distance of 1 – 10 (map units, metres in this example) It is good to not have the points overlapping but not essential as we will mitigate this at a later stage. If you set this too high there may not be room for all the dots in the smaller boroughs.
  4. Save your file as a new Geopackage (or shapefile if you want to). These files will be quite big so it is best not to create a temporary layer.
  5. Click Run.  It will take a while as the algorithm has to cycle through the 33 boroughs.

Once the process has finished you will have points all over the map within the boundaries of the London Boroughs.  However the new layer added will be called Random Points in the layers panel.  We will need to change this before we create a similar file for the votes to remain.

  • Right-click on Random Points in the layers panel.
  • Click Rename and change the name to be 100 leave votes.

Now rerun the Random points inside polygons (variable) for the remain votes. Use the same process as above, but use 100 Remain Votes as the Number Value, call the new geopackage Remain Dots, and finally rename the layer in the layers panel to be 100 remain votes.

The map will now look something like this:

Styling the Map

As it stands this map is rather useless, the points are all overlapping and you can’t see the leave votes as the remain all lie over the top of them. Thankfully we can use the power of QGIS to style the points in a way that makes gives equal emphasis to dots from each layer.

First let’s style the London Borough polygons so that they don’t interfere with the dots.

  • Click on the LondonBoroughsEURef in the layers panel to highlight it and then press F7 on your keyboard to open the Live Style Dock on the right side of the map.
  • Click Simple Fill at the top of the Layer Styling panel.
  • Change the Fill to Transparent.
  • Change the Outline Width to be 0.6

The Outlines will now be clear but there will be no fill colour to interfere with the dots. We can now move on to styling the points.

We need to reduce the size of the points, so the map isn’t too crowded and give them a good colour. We also need to set a blend mode to account for any over lapping points.

  1. Use the drop down menu at the top of the Layer Styling panel to change the layer to 100 Remain Votes.
  2. Click Simple Marker to reveal more options.
  3. Set the Size to be 0.6 (Millimeters).
  4. Set the Outline Style to be No Pen.
  5. Set the Layer lending mode to be Multiply
  6. Set the Feature blending mode to be Multiply
  7. For Fill, click on the colour swatch.

We want to set this as red but we want to take down the saturation. This is to allow overlapping features to have a stronger colour; either a strong red where two features in the same layer are blended or a purple where there is overlap with the blue leave dots.

By picking colours of the same intensity we have also made sure that the map has minimal bias to one colour or the other. This is also maintained by the use of the Blend modes which mix into purple and so minimise the bias where one dot may have overlapped another of a different colour.

On the colour chart:

  1. Set R(ed) to be 255 (Full) and G(reen) and B(lue) to be 0.
  2. Go up to S(aturation) and bring this down to 70% making the red lighter. You will notice that the G and B values increase to 76.

The colour now has scope to increase its intensity if it overlaps with another dot.

Repeat the process above with the 100 leave votes layer except here we are going to use blue.  Just make sure you increase B(lue) to 255 rather than R(ed) when selecting the colour.

The map will now look like this, it works at  scales between 1:200,000 and 1:400,000.  You will need to have less dots if you want to zoom out further, or more or larger dots on a more zoomed in map.

Contains OS data © Crown copyright and database right (2017)

So you should now be able to make the distinction between the largely remain voting central London compared to the periphery where voting leave was more popular, particularly in the West.

Labelling

The final thing you can do to your map is add labels to the London Boroughs so you can tell which is which. With such a busy map we are going to need buffers round the text.

  1. On the Layer Styling panel, change to LondonBoroughEURef then switch to the Labels tab: 
  2. Change to show labels for this layer.
  3. Change Label with to NAME.
  4. Choose a weightier font, I have used Franklin Gothic Demi.

Next we need to work on the formatting of the text so click on the format tab:

 

 

 

  1. Enter a space in the Wrap on Character field.
  2. Change the Alignment to Center.

The labels will now be better placed over the boroughs, though there won’t be enough room for them all unless you are more zoomed in.

 

The final steps are to add a mask or buffer to the text to make it stand out over the dots.

Click on the Buffer tab to start making changes:  

  1. Click the cross to Draw text buffer.
  2. I have left the Size as 1, but you may want to change this depending on your font.
  3. Set the buffer’s Transparency to something like 33% to allow some colour to show through.

That is the end of the instructions, you should have a map that looks similar to the one below:

Contains OS data © Crown copyright and database right (2017)

Creating 3D choropleth or prism map in QGIS 2.18

Contains OS data © Crown copyright and database right (2017)

It is possible to very quickly render any choropleth map you make in QGIS in 3D using the Qgis2threejs plugin. Essentially the plugin allows you to turn a numerical attribute as a “height” for your data. The results from the plugin are outputted as an html page which can be easily shared in a folder or placed on the web for people to view.

The Data

Votes:

The Electoral Commission website contains a lot of data that can be used for making choropleth maps of all kinds. For this post I have used the EU Referendum results .CSV file:

https://www.electoralcommission.org.uk/__data/assets/file/0014/212135/EU-referendum-result-data.csv

Boundaries:

If you are making choropleth maps of Great Britain then the best place to start with when looking for boundaries is the Ordnance Survey’s Boundary-Line Data:

https://www.ordnancesurvey.co.uk/opendatadownload/products.html#BDLINE

The Method

I have used the data above to create a shapefile of London Boroughs with attributes that include the total number of votes, the number of votes to remain in the EU, and the number of votes to leave from the 2016 EU referendum. This was done using a table join based on the Area_Code from the result data CSV and the CODE in the Boundary-Line data for the London Boroughs.

The new file is called London Borough EU Ref and you can download a copy here: LondonBoroughEURef.zip

I have also added in a Stamen Toner (Retina) basemap using the method described here: Adding web Basemaps in QGIS 2.18

Adding Qgis2threejs

To start creating your Prism Map you will need to add in the Qgis2threejs plugin using the Manage and Install Plugins interface:

Once installed you access the plugin via the Web menu in the top bar:

Setting up the data

Before we can get to work creating a 3D map we need to set up the data in the 2D map. In this example we are going to show the number of votes in the referendum for the London Boroughs as the 3D height, however we have the option to use the colour of the boroughs to show a second attribute. It is actually very useful to make the polygons different colours as it is then easier to interpret the map.

  1. Right-click on the London Borough EU Ref layer and select Open Attribute Table
  2. In the attribute table window click on the Field Calculator Button:

In the field calculator window we need to do the following:

  1. Check Create a new field
  2. Set the Output field name to be %_Remain
  3. Set the Output field type to be Decimal number (real)
  4. the Output field length can stay at 10 but set the Precision to be 2
  5. In the expression window create the following statement:

    ( “Vote_Remai” / “votes” ) * 100

  6. Click OK

You will now see the new column in the attribute table but you still need to save your change and turn off editing mode.

  1. Click on the Save Edits button:
  2. Click on the Edit Mode off button:

Styling the data

We can now apply a graduated colour scheme based on this new column.

  1. Press F7 on the keyboard to open the Layer Styling dock on the right side of the map
  2. Make sure you are editing the London Borough EU Ref layer at the top
  3. Change the Single Symbol option to Graduated
  4. Change the Column to %_Remain
  5. Change the Color ramp to RdBu (Red to Blue through White)
  6. Check the Invert option (this makes leave favouring areas blue and remain red, the standard colours adopted for the referendum results)
  7. Change the number of Classes to 7
  8. Set the Mode to be Equal Interval
  9. Click Classify
  10. Manually adjust the Values to 10% bands, starting at 20% votes to remain through to 80% votes to remain. Make sure that white represents 50%. If you double click in the the value column of the table in the Layer Styling dock it will open a window where you can edit each entry:
  11. Finally change the Layer Blending Mode to Multiply so that you can see the details of the base map through the colours with no nasty washed out effect you get with transparency. This effect works particularly well on the black and white basemap.

The resulting map is shown below, with the areas of the lowest votes to remain as the darkest blue, white represents 50%, and the darkest red in the areas with the most votes to remain:

Map data © OpenStreetMap contributors, Contains OS data © Crown copyright and database right (2017)

The Prism maps produced by Qgis2threejs show a flat plane with extruded blocks extending upwards. The flat plane will appear as it is in the map window. It can be good to have a little transparency on the extruded blocks and so you don’t want the colours you have just set interfering with this. However it can be useful to see the boundaries you are extruding upwards. To show these:

  • Right-click on the London Borough layer
  • Select Duplicate

You will end up with a copy of the layer called London Borough EU Ref copy

Style the new layer to show just the outlines:

  1. Set the style to be Single symbol, Simple fill
  2. Se the Fill to be Tranparent
  3. Set the Outline to be Black
  4. Increase the Outline width to 0.7 so it will show up a bit more clearly
Contains OS data © Crown copyright and database right (2017)

Preparing the map for conversion to 3D

You should now turn off the coloured London Boroughs layer and use the Zoom to Layer Extent to set up the map as show below:

Map data © OpenStreetMap contributors, Contains OS data © Crown copyright and database right (2017)

Setting up Qgis2threejs

You can now open the Qgis2threejs plugin from the Web menu:

There are a a whole raft of options to look at with this plugin as it can be used not only for Prism Maps but for accurate 3D landscape models too.

We’ll run through the changes needed to make a Prism Map, the rest of the parameters can be left as the default settings.

Well start at the top of the menu on the left:

World

The only thing to change here is the Background colour. The default is sky which works well for landscapes but I have set this to black which works better for the colours of this map.

Controls

This can be left as the defaults.

DEM

The only thing to change here is to scroll down and switch off the Build Sides option.

Additional DEM

This can be left as the defaults.

Polygons

  1. First we need to set which polygon layer we are going to extrude up, check the box next to London Borough EU Votes.
  2. The main thing to change here is to set the Height value to be Votes
  3. multiplier to be 0.1. The values are set in map units but as there were so many votes this makes the Prisms too high. if you are dealing with low values over larger areas then you will need a high multiplier to see any effect.

The Results

So now you are ready to Run the plugin, I tend to leave the location to be the temp folder while I play around with the colours, zoom levels and height multipliers. Once you are happy then you can set your location and the plugin will create a folder there with all the information needed to create the html page:

Here is the result:

Map data © OpenStreetMap contributors, Contains OS data © Crown copyright and database right (2017)

Note that the website can take a while to generate and the more complicated the geometries of the polygons the longer it takes to render. Microsoft Edge and Internet Explorer can take a bit longer to display than FireFox and Chrome, but once loaded all browsers tend to run well.

One thing I have found is that the models look better when the polygons are simple. American States, which have a lot of straight lines, tend to work better than UK counties or constituencies. Here is the same data for London, but put into HexBins. I’ve added labels to help identify which hexagon represents which borough.

It is possible to edit the CSS to change things like the font and text size for the labels.

Map data © OpenStreetMap contributors

Here is a link to the actual model created:

London Remain Votes Prism Map

Adding web basemaps in QGIS 2.18

This is a very quick guide on adding web basemaps to QGIS 2.18.  I’ve created it as it is often the first step in creating a new map.

The easiest way to add in a basemap from the web is to use one of two plugins to add in the data for you. The two best plugins I have found for doing this are the OpenLayers and QuickMapServices.

OpenLayers:

The OpenLayers plugin from Sourcepole allows you to add in maps layers like OpenStreetMap (Including brilliant styles from Thunderforest and Stamen), Bing, Google and Apple.

The layers area accessed via the Web menu in the top bar of QGIS

The maps are called using their official Javascript API, making them very reliable. The only issue I have encountered is that the maps are slow to return; though I haven’t recently experienced the blank, un-returned tiles that used to blight this plugin in the past.

Use the drop down menus to choose a layer and then simply click on it to add it to your map.

QuickMapServices:

QuickMapServices from NextGIS has a huge number of services available (790 at the last count, but not all of them are active ) . You can select a few of these using the same select and click method as the OpenLayers plugin, but as there are so many to choose from the search interface is a much needed facility:

Once selected from the menu the Search QMS window opens on the right side of the map:

Once you have found a service you want, just click Add. There is a full cataloge on the NextGIS website here: https://qms.nextgis.com/

Along with the regular Web Mapping Services (WMS) you can also get Tile Map Services (TMS), Web Feature Services (WFS) and GeoJSON data piped straight into your map.

I have found layers added via QMS to be much quicker than those added using OpenLayers, however some layers are a little less stable and sometimes all layers from the plugin refuse to work without restarting QGIS.

Verdict:

OpenLayers is steady and stable and can usually be relied upon to provide you with maps. QMS has a much larger range of maps available and serves them up lightning fast, great for backdrop maps when making animated maps with the TimeManager plugin.

Basically, have them both installed and use whichever suits your project!

Creating a Proportional Symbol map in QGIS 2.18

Creating proportional symbol maps in QGIS is made very easy in QGIS with two main methods for making them. You can use basic Single Symbol style with the  Size Assistant in the Data Defined Override,  or you can use the Graduated style and choose Size as the method of gradation. Below is a set of instructions on how to use either method to create proportional point symbols for your map.

The Data

  • Download the 1:10 million populated places (Simple) Shapefile from Natural Earth:
  • Add in the Stamen Toner Lite WMS using either the OpenLayers or QuickMapServices plugins. If you haven’t done that before, here is a quick guide:

Method 1: Graduated Symbols

This method works best when you want to use all the points in your dataset. QGIS allows you to vary the size of the data point based on the values in attributes of the data.

  • First, open the live layer styling menu by pressing F7.

Make sure the top menu is set to the Natural Earth Point data then change Single symbol to be Graduated.

There are now a few new options to play with:

  • Change Column to be pop_max
  • Change Method to Size
  • Change “Size from” to 3 and “to” to 20
  • Click the Classify button to see how this looks.

The map will automatically update to look like the map show below, zoomed in to the UK and Northwest France:

You have flexibility to change the number of classes and how you divide the classes, Equal Interval, Quantiles, Natural Breaks etc. You can also manually edit the classes by double click in the values column in the table.

Method 2: Data Defined Override

If you want a little more control over how the data is displayed this method allows you to quickly change maximum and minimum values without having to set each level in between.

  • First, open the live layer styling menu by pressing F7
  • Make sure the top menu is set to the Natural Earth Point data
  • Click on the Data Driven Override button  on Size

 

 

  • Click on the Size Assistant option at the bottom of the box.

You will now be looking at the Size Assistant dialog. The options here are very similar to using the method described above, allowing you to select the field to base the size on and having control over size of the points.

  • Set the Field to be POP_MAX
  • Set the Scale method to be Radius
  • Change the “Size from” to be 3 and “to” to be 20

As you can see in the example above the symbols automatically scale from the smallest to the largest values in the field selected. However where this method has a big advantage over the previous one you can set the upper limit to be different. The points will now automatically scale to this value without you having to manually update each range. This can be very useful if you are viewing only a portion of the data.

In the area we zoomed to in the previous method the largest cities are London and Paris, both having a population of below 10,000,000

  • Change the “Values from” to be 0 and “to10,000,000

You can now see int he map below there is a bigger range of point sizes than the previous method for the area of the map.

Blend Modes

A little added tip is to use the blend modes on your symbology, so you can see the basemap through the shapes and reveal the detail on any overlapping symbols:

  • In the Layer Rendering section of the style tab change the Layer blending mode to be Multiply. This will allow you to see the basemap through the points
  • Change the Feature blending mode to be Multiply. This will allow you to see overlapping points within the point dataset.

The Result: