Skip to content
Learn QGIS with BNHR

Module 1 · Intermediate

Map layouts and elements

This module discusses map layout concepts, elements, and templates.

Module 1Level IntermediateExercises 1.1–3.2
On this page
  1. Overview
  2. Introduction
  3. What you should already know
  4. Layout templates
  5. Review of the Print Layout
  6. Page Properties
  7. Ex 1.1 · Saving and opening a template
  8. Map themes
  9. Creating map themes
  10. Ex 2.1 · Adding multiple maps to the same layout
  11. BONUS: What if you want to clip the inset map so that it looks like a circle (or any other shape)?
  12. Plots, tables, and other map elements
  13. Adding tables to maps
  14. Ex 3.1 · Show a table of the top 5 regions with the most confirmed cases
  15. Adding graphs/plots to maps
  16. Ex 3.2 · Add a bar graph of the provinces with active cases > 500
  17. Certification and support

This module discusses map layout concepts, elements, and templates.

As an intermediate level workbook, you are expected to already know basic GIS concepts such as spatial data models and formats and QGIS functions such as loading and styling layers, running processing algorithms, saving QGIS projects, etc.

  1. To review the Print Layout and learn about layout templates

The Print Layout window can be accessed via Project > New Print Layout in the Menu bar or CTRL + P. QGIS also has a layout manager (Project > Layout Manager) that allows you to manage (add, delete, duplicate) print layouts related to a project.

A Print Layout is saved together with the QGIS project and is not available outside of the QGIS project where it is used. However, QGIS has templates which can be used for different projects. A plugin, Layout Loader, can also be used for applying layout templates to your maps.

The option to edit the page properties of your layout such as the size, orientation, and background color (if any) can be done Right clicking on an empty part of the the layout canvas > Page Properties.

Opening the layout’s page properties
Fig. 11. Opening the layout’s page properties
Page properties options
Fig. 12. Page properties options

Exercise 1.1. Saving and opening a template

Section titled “Exercise 1.1. Saving and opening a template”

QGIS allows you to create and manage layout templates that are reusable across QGIS instances. This is very useful when you need to create standard layouts and maps across different users, machines, and even offices.

Layout templates in QGIS have the file extension .qpt. The templates for a user profile are stored inside the composer_templates folder of that user profile. You can manually add layout template files to this folder and they will become available to the user.

  1. After you’re done creating a Print Layout, you can save it as a template by going to Layout > Save as Template…
Saving as a layout template
Fig. 13. Saving as a layout template
  1. Two sample templates are included in the data folder:

    • Simple A4 Landscape
    • Standard A3 Landscape
  2. Open one of them by double-clicking or dragging them to QGIS and inspect the contents of the layout.

The content of the Standard A3 Portrait template
Fig. 14. The content of the Standard A3 Portrait template
  1. Another way to use a template is to save them in the composer_templates folder of the user profile. Afterwards, you can use the template in any Print Layout by going to Layout > Add Items from Template.
Adding a template to a layout
Fig. 15. Adding a template to a layout
Items of Simple A4 Landscape Template loaded in the Layout 3 layout
Fig. 16. Items of Simple A4 Landscape Template loaded in the Layout 3 layout
  1. Learn what map themes are how they are created.
  2. Use map themes in the Print Layout.

A map theme is a snapshot of the current map legend that records:

  • the layers set as visible in the Layers panel and
  • for each visible layer:
    • the reference to the style applied to the layer
    • the visible classes of the style (i.e. the layer checked node items in the Layers panel. This applies to symbologies other than the single symbol rendering)
    • the collapsed/expanded state of the layer node(s) and the group(s) it’s placed inside

Map theme options can be found in the Layer panel via the Map Themes icon button.

To create a map theme:

  1. Check the layer/s you want to show.
  2. Configure the layer properties (symbology, diagram, labels, etc).
    1. Expand the Style ‣ menu at the bottom of the Styling Panel.
    2. Click on Add… to store the settings as a new style embedded in the project.
  3. Repeat the previous steps as necessary for the other layers.
  4. If applicable, expand or collapse groups or visible layer nodes in the Layers panel.
  5. Click on the Manage Map Themes button (Map Themes icon) on top of the panel and click Add Theme
  6. Enter the map theme’s name and click OK.
  7. Your themes are listed under the Map Themes icon button.

A map theme does not remember the current details of the properties: only a reference to the style name is saved, so whenever you apply modifications to the layer while this style is enabled (e.g. change the symbology rendering), the map theme is updated with new information.

You can create as many map themes as needed.

Map themes allow you to quickly switch between different configurations of the layers in your map. Also, since map themes are available in the Print Layout, they allow you to create map items based on the themes and independent of the current rendering or appearance of the main canvas. This is extremely useful when adding multiple maps in a layout (e.g. insets, etc.).

Exercise 2.1. Adding multiple maps to the same layout

Section titled “Exercise 2.1. Adding multiple maps to the same layout”

Output of Exercise 2.1. Adding multiple maps to the same layout

For our training participants, you can load the completed/styled layer by loading the 2.1 multiple-maps project found inside bnhr_working-with-maps-and-layouts.gpkg.

In this exercise, you will utilize map themes in order to add the two maps to a single layout. You will create a map showing the COVID cases in the Philippine provinces with an inset map showing the location of the Philippines in the world.

  1. Load the stompcovidph_provinces layer and apply a Graduated symbology like below.
stompcovidph_provinces layer with graduated symbology
Fig. 21.1. stompcovidph_provinces layer with graduated symbology
  1. Load a world layer and apply a rule-based symbology highlighting the Philippines. This will serve as our inset map in the Print Layout.
World map layer with rule based symbology highlighting the Philippines
Fig. 21.2. World map layer with rule based symbology highlighting the Philippines
  1. Set the stompcovidph_provinces layer as the only visible layer (checked in the Layers Panel). Add a theme by clicking Map Themes icon > Add New Theme. Name the theme covidph.
Add covidph theme (only stompcovidph_provinces layer is visible)
Fig. 21.3. Add covidph theme (only stompcovidph_provinces layer is visible)
Naming the map theme
Fig. 21.4. Naming the map theme
  1. Do the same for the World Map layer. Make it the only visible layer and add a theme by clicking Map Themes icon > Add New Theme. Name it world.

  2. The map themes are listed under Map Themes icon and can be activated/deactivated any time. Try it.

Two map themes (covidph and world)
Fig. 21.5. Two map themes (covidph and world)

Map themes can also be accessed in the Print Layout.

  1. Open a print layout and add some basic components (e.g. title, north arrow, scale bar).
  2. Add a map. In the Item Properties of the Map, set:
    • Layers
      • Check Follow map theme
      • Select covidph
Follow map theme
Fig. 21.6. Follow map theme

When you specify that a map element “follow a map theme”, it will show the map theme regardless of what’s visible in the map canvas.

Aside from map themes, you can also use the Lock layers option under Layers in the Print Layout to replicate this behavior.

Aside from map themes, you can also use the Lock layers option under Layers in the Print Layout to replicate this behavior.

  1. Add another map element. This time make it smaller and place it in the upper right corner of the page. In the Item Properties of the Map, set:
    • Layers
      • Check Follow map theme
      • Select world
  2. Add a legend.
The world theme used in the inset map
Fig. 21.7. The world theme used in the inset map

BONUS: What if you want to clip the inset map so that it looks like a circle (or any other shape)?

Section titled “BONUS: What if you want to clip the inset map so that it looks like a circle (or any other shape)?”

QGIS makes it easy to clip map elements. In the Map properties toolbar, the rightmost button will open the Clipping settings that will allow you to define how you want the map to be clipped.

Clipping settings in the Map properties toolbar
Fig. 21.8. Clipping settings in the Map properties toolbar
  1. Add a circular shape to the map using the Add Shape > Add Ellipse command. You will use this to clip the inset map to its shape. Place this circle over the inset map where you want it to be clipped.
Shape element placed in the area where we want it to clip the inset map
Fig. 21.9. Shape element placed in the area where we want it to clip the inset map
  1. Go to the Clipping Settings of the inset map, check Clip to Item, and select Ellipse.
Clipping settings for the inset map
Fig. 21.10. Clipping settings for the inset map
  1. You can continue to fine-tune your layout. It should look similar to the one below.
Layout with 2 maps using map themes
Fig. 21.11. Layout with 2 maps using map themes
  1. Learn how to add plots and tables in the Print Layout.

Aside from common map elements such as labels, scale bar, and legends, the QGIS Print Layout also allows for other map elements such as tables and plots to be added to the map. For tables, these can be fixed tables or based on the attribute table of layers.

For plots, they can be added using plugins such as the DataPlotly plugin (https://plugins.qgis.org/plugins/DataPlotly/) for graphs (bar, chart, pie, line) or natively such as with Elevation profiles.

Exercise 3.1. Show a table of the top 5 regions with the most confirmed cases

Section titled “Exercise 3.1. Show a table of the top 5 regions with the most confirmed cases”

Output of Exercise 3.1. Show a table of the top 5 regions with the most confirmed cases

For our training participants, you can load the completed/styled layer by loading the 3.1 add-table project found inside bnhr_working-with-maps-and-layouts.gpkg.

In this exercise, we will add a table showing the top 5 regions with the most confirmed cases based on our stompcovidph_provinces layer.

  1. Remove the inset map from the layout you created in the previous exercise.
  2. Add an attribute table to the layout by clicking Add attribute table button.
  3. On the Item Properties Panel,
    • Set Maximum rows to 5
    • Check Remove duplicate rows from table
    • Click Attributes…
Item properties of the table
Fig. 31.1. Item properties of the table
  1. On the Select Attributes window…
    1. Remove all attributes so that only region remains
    2. Add 2 new columns by clicking on the green plus button.
      • confirmed cases in the region using the expression:
        sum(confirmed, region)
      • active cases in the region using the expression:
        sum(active, region)
    3. Add a new sorting by clicking on the green plus button.
      • Attribute is:
        sum(confirmed, region)
      • Sort Order: Descending
Adding the attributes that will be shown in the table
Fig. 31.2. Adding the attributes that will be shown in the table
Table of top 5 regions with confirmed cases added to the layout
Fig. 31.3. Table of top 5 regions with confirmed cases added to the layout

Aside from tables, you can also add plots in the layout via the Data Plotly plugin.

In order to add plots to the Print Layout using the Data Plotly plugin, make sure that you have the said plugin installed and activated.

Exercise 3.2. Add a bar graph of the provinces with active cases > 500

Section titled “Exercise 3.2. Add a bar graph of the provinces with active cases > 500”

Output of Exercise 3.2. Add a bar graph of the provinces with active cases > 500

For our training participants, you can load the completed/styled layer by loading the 3.2 add-plots project found inside bnhr_working-with-maps-and-layouts.gpkg.

  1. Add plots by clicking the add plot icon Add plot button usually found at the bottom of the rightmost panel or in the Add Item menu.
  2. In the Item Properties click Setup Selected Plot with the following parameters.
Plot properties (1)
Fig. 32.1. Plot properties (1)
Plot properties (2)
Fig. 32.2. Plot properties (1)
  1. Use a Feature subset to limit the features to be plotted to those where the active cases > 500. Use the expression:
    active > 500
The feature subset using an expression
Fig. 32.3. The feature subset using an expression
Plot added to the layout
Fig. 32.4. Plot added to the layout
Saved in this browser only

Certification and support

We offer additional resources, certificates, official QGIS certification, ongoing support, and other perks to those who join our instructor-led training.

Join an upcoming training to take this as an instructor-led course, or contact us to arrange one for your team or organization.

Something new

Identify results
LayerDid you know?
TopicOpen source
FactSteve Coast founded OpenStreetMap in 2004. Its first contribution was a street he entered on December 10, 2004, after cycling around London's Regent's Park with a GPS receiver.
SourceHistory of OpenStreetMap (OpenStreetMap Wiki) (opens in a new tab) ↗
LinkShare this fact