Skip to content

Map layouts and elements

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.

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.

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

Figure 1.1. Opening the layout’s page properties

Page properties options

Figure 1.2. 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.

  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

Figure 1.3. 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

Figure 1.4. 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

Figure 1.5. Adding a template to a layout

Items of Simple A4 Landscape Template loaded in the Layout 3 layout

Figure 1.6. Items of Simple A4 Landscape Template loaded in the Layout 3 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.

Creating map themes 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.

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

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

Figure 2.1.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

Figure 2.1.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)

Figure 2.1.3. Add covidph theme (only stompcovidph_provinces layer is visible)

Naming the map theme

Figure 2.1.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. These map themes can also be accessed in the Print Layout.

Two map themes (covidph and world)

Figure 2.1.5. Two map themes (covidph and world)

  1. The map themes are listed under Map Themes icon and can be activated/deactivated any time. Try it. These map themes can also be accessed in the Print Layout.
  2. Open a print layout and add some basic components (e.g. title, north arrow, scale bar).
  3. Add a map. In the Item Properties of the Map, set:
    • Layers
      • Check Follow map theme
      • Select covidph

Follow map theme

Figure 2.1.6. Follow map theme

  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

Figure 2.1.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

Figure 2.1.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

Figure 2.1.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

Figure 2.1.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

Figure 2.1.11. Layout with 2 maps using map themes

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

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, a. Set Maximum rows to 5 b. Check Remove duplicate rows from table c. Click Attributes…

Item properties of the table

Figure 3.1.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

Figure 3.1.2. Adding the attributes that will be shown in the table

Table of top 5 regions with confirmed cases added to the layout

Figure 3.1.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.

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

  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)

Figure 3.2.1. Plot properties (1)

Plot properties (2)

Figure 3.2.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

Figure 3.2.3. The feature subset using an expression

Plot added to the layout

Figure 3.2.4. Plot added to the layout

Contact us or sign-up to our courses if you are interested in having this as an instructor-led or self-paced course.