QGIS Tutorial 3 - Add World Bank Data to QGIS Country shapefile

Jeremy M. Mikecz


498 Home Syllabus Schedule Mikecz Home Tutorials

  1. From Slack #datasets, download the World Bank 2016 dataset and save it in your

  2. Open your QGIS project.

  3. Download the WB dataset (Layer –> Add Layer –> Add Vector Layer [set encoding as ‘UTF-8’])

  4. You will eventually notice one problem with this new dataset. Many of its numerical values are saved as “strings.” That means we will not be able to run statistical calculations or create maps based on numerical values from this data. To address this problem, we must convert these columns to numerical data (more specifically, “doubles” rather than integers). There are several ways to do this. One way (taken from here, click on this link to see photos of these steps) is described below:

    a.  To change the datatype we are going to use the refactor field tool, located within the QGIS processing toolbox. To find the toolbox click on the **Processing dropdown menu** and select **Toolbox**.
    b. In the **Toolbox window** (should be on the right side of the screen, search for **"refactor**. Select **Refactor fields**.
    c. In the **Refactor Fields window** scroll down to find the World Bank data columns. For the fields (columns) that are percentages you will want to change them to **double** data with a length of 6 (i.e. 100.00) and a precision of 2 (i.e. 91.23). For fields that are absolute numbers, you will have to examine the data to identify the likely maximum value. For example, the richest countries have a per capita GDP in the 100,000s. Therefore, you may want to select a data type as integer with a length of 6.
  5. To join this World Bank data with your existing countries shapefile (source of these instructions)

    1. Open the countries shapefile’s Properties window
    2. Select the “Joins” tab
    3. Press “+” to add the dataset to your shapefile
    4. Join layer: select the World Bank dataset you imported
    5. Join field: select the ‘id’ columns
    6. Target field: select the ‘ADM0_A3’ column.
    7. Click OK
  1. To view this new data and see if the join performed correctly, open the Attribute table for your countries shapefile and scroll through the data to see that all fields (variables / columns) were added.

  2. To display this data, open the Properties window, select the Symbology tab and then choose Graduated. Now that we have properly changed the data types of this numerical data, you can now choose the World Bank data columns to display them in the form of chloropleth maps. To do so:

    1. Select the data you want to display from the Column menu.
    2. Choose a color ramp. Since we are displaying continuous numerical data, choose a one-color color ramp (like “Greens” or “Reds”).
    3. Select a Classification Mode and set a particular number of Classes. I recommend starting with “Natural Breaks” and 10.
    4. Press OK or Apply to display your new map.
  3. If you wish to save a particular map, pan and zoom to the best view of the map, save the view as a Spatial Bookmark (so you easily can return to it later) and then select Project –> Export Map to Image. Export your map to your QGIS folder.

Create a Print Layout of your Maps

  1. To create quality, reproducible maps to export (or print) from your QGIS project we will work with the Layout window.

  2. Select Project –> New Print Layout. Give your new layout a name, perhaps something like “world-horizontal”.

  3. From within your new Layout window (if it didn’t open automatically select Project –> Layouts –> [name of your new layout]) select Add New Map. Drag the map to cover the entirety of your page (note: if you were printing then you may want to leave margins on the edges).

  4. You can resize the map, zoom in or out, or pan to center a different position on the map.

  5. Now add a map title and legend. For directions how to do so, see the QGIS documentation for Print Layouts, starting with 5.1.2 for more information.

  1. To add a compass, select Add Item –> Add Picture.

    1. Draw a box where you would like to add the compass.

    2. On the right side of the Layout window there should be an Items Window. Select the new menu item and then under item properties open the Search directories menu. From there you may choose a compass symbol.

  2. In a future lesson we will add a scale bar. However, working in the Pseudo-Mercator projection makes measuring distances a problem….

Exercise: Telling a Data Story

Create three chloropleth maps from the World Bank data. Choose three related variables for these maps that will allow you to tell a story. Export the three maps. Present your maps and tell the story of this data in class.