Skip to content

The QGIS Atlas

Before diving into this module’s exercises, it would be good if you can review and familiarize yourself with the QGIS Atlas.

QGIS Atlas allows you to automatically create a series of maps using a single layout. A properly configured QGIS Atlas will save you countless hours.

3.1. District map of Quezon City showing population statistics per barangay

Section titled “3.1. District map of Quezon City showing population statistics per barangay”
Level: Intermediate

Output for 3.1. District map of Quezon City showing population statistics per barangay

In this exercise, you will take the adm_brgy_quezon_city_pop2000_2020 layer and create an Atlas that generates one map per district but shows information about the barangays inside that district. To do that, you will utilize data-defined overrides and expressions.

  1. Load the adm_brgy_quezon_city_pop2000_2020 layer and apply a graduated symbology using the pop2020 field.

adm_brgy_quezon_city_pop2000_2020 layer with graduated symbology

  1. Load the adm_dist_quezon_city_pop2000_2020 layer. No need to style this layer right now. You will use this layer as your coverage layer.
  1. Create a new Print Layout and add a map.

Map added to the print layout

  1. Let’s configure your Atlas. Click the Configure Atlas button Atlas icon on the top toolbar to open the Atlas Settings.

  2. Check Generate an atlas and apply the following parameters:

    • Configuration
      • Coverage layer: adm_dist_quezon_city_pop2000_2020
      • Page name: region

Atlas configuration (1)

  1. Modify the Item Properties of the Map and check Controlled by Atlas.

Setting map properties to be Controlled by Atlas

  1. Click the Atlas button (Atlas icon) on the top toolbar to preview your atlas.

Atlas toolbar

Atlas toolbar

  1. The Atlas Toolbar shown below allows you to see the different maps in your atlas. Try to click the arrow buttons and see what happens to the map.

Atlas active

Atlas active

Simple atlas functionality

Simple atlas functionality

Although your atlas does what it’s supposed to—which is to generate a map for each district automatically—it doesn’t look that appealing. What you can do is to utilize some techniques to improve the map.

  1. Using this approach, you can apply a style to the districts layer such that when it is the feature being used by the atlas, it will cover all other features outside of itself. In essence, this just means that you will apply an Inverted Polygon symbology to the current atlas feature.
  2. This can easily be done by combining rule-based symbology, inverted polygon symbology, and expressions.
  3. Apply the following styles to the stompcovidph_regions layer: Inverted Polygons with a Rule-based Sub renderer.
  4. Create a rule to get the current atlas feature by using this expression:
    $id = @atlas_featureid

Styling the districts layer to cover other features outside the current atlas feature

Styling the districts layer to cover other features outside the current atlas feature

  1. As long as the adm_dist_quezon_city_pop2000_2020 layer is rendered above the adm_brgy_quezon_city_pop2000_2020 layer, then you should see a map canvas similar to the one below.

The districts layer covering the other features outsidethe current atlas feature

The districts layer covering the other features outsidethe current atlas feature

  1. This also reflects on the Print Layout and you should see something similar in the Atlas you created.

Atlas showing only the region of interest (1)

Atlas showing only the region of interest (1)

Option 2: Using expressions to filter the brgy layer

Section titled “Option 2: Using expressions to filter the brgy layer”

The second option is to apply the same kind of filter directly to the adm_brgy_quezon_city_pop2000_2020 layer. In this case, you can use an expression that checks if a barangay is inside of a district and if yes, it will style the barangay. If not, it will not apply any styles (e.g. make it not visible).

This can be done by using a refined/nested rule-based symbology where the topmost rule checks whether or not a province is within a region (spatially) and the sub-rules apply the symbology.

  1. Apply the following style to the adm_brgy_quezon_city_pop2000_2020 layer.
  2. The topmost rule uses the following expression:
    within($geometry, @atlas_geometry)

Rules for styling only the barangays that are within (spatially) the current atlas feature (district)

Rules for styling only the barangays that are within (spatially) the current atlas feature (district)

  1. Your map canvas should look like below:

Map showing only the provinces within (spatially) the current atlas feature (region)

Figure 4.1.11. Map showing only the provinces within (spatially) the current atlas feature (region)

  1. Similar to the first option, this also reflects in the Atlas or Print Layout.

Atlas showing only the region of interest (2)

Atlas showing only the region of interest (2)

You can select which approach you like better.

In the next section, you will be adding more data-defined elements to your Atlas such as a texts, legends, and tables that change depending on the current atlas feature being mapped.

  1. Add a data-defined label to your map that shows the name of the district.

Using dynamic texts for the map title

Using dynamic texts for the map title

  1. Add a legend to the map. You can make this legend only show the items inside the current atlas feature.

Setup legend to only show items inside the current atlas feature

Setup legend to only show items inside the current atlas feature

Adding a table that shows only the barangays in the district

Section titled “Adding a table that shows only the barangays in the district”

You can use the same expression you used to filter the barangays inside the district to make a table that only shows those barangays.

  1. Add a table to the map and define the table using the following columns.

Column definitions for the table

Column definitions for the table

  1. Under Feature Filtering:
    • Set Maximum rows to 10
    • Check Remove duplicate rows from table
    • Check Filter with and use the following expression:
      within($geometry, @atlas_geometry)

Atlas with data-defined table

Properties of data-defined table (1)

  1. You can also define the reference/anchor point of the table to control how it will change size.

Setting reference point to be lower right

Setting reference point to be lower right

  1. Feel free to edit the look and feel of your table.

Atlas with data-defined table

Atlas with data-defined table

Similarly, you can use the same expression to filter the plots you add to your map.

  1. Create the same bar plot you did in one of the previous exercises.

  2. Under Feature subset use the following expression:

    within($geometry, @atlas_geometry)

Setup an atlas-defined plot

Setup an atlas-defined plot

  1. The plot should change values depending on the current atlas feature being mapped.

Atlas with data-defined plot

Atlas with data-defined plot

Completed Atlas

Completed atlas with data-defined elements

  1. You can add other map items/elements and configure them as you like—e.g. scalebar, north arrow, etc.

  2. Once you’re happy with your Atlas, you can Export your atlas as images by clicking Save Map as Image button. Depending on how you configured your atlas, this may result in a single image or multiple images (1 per map).

Atlas that iterates over the same area/coverage

Section titled “Atlas that iterates over the same area/coverage”

3.2. Mapping flood hazard levels for one district in Quezon City

Section titled “3.2. Mapping flood hazard levels for one district in Quezon City”
Level: Intermediate

Output of 3.2. Mapping flood hazard levels for one district in Quezon City

In this exercise, you will utilize an atlas to map the same area but showing different things (e.g. phenomena, attributes, etc.). In this case, you will create four maps of the same QC district showing the (1) low flood hazard, (2) moderate flood hazard, (3) high flood hazard, and (4) all flood hazard areas using an atlas by combining rule-based symbology, expressions, and a creative use of the coverage layer.

To do this, you need:

  • a coverage layer (coverage_layer_district) that:
    • covers the extent of the 2nd District
    • has 4 features (1 for each map)
    • has a “hazard” attribute/field corresponding to one of the hazard levels being mapped

Attribute table of the coverage layer

Attribute table of the coverage layer

  1. Load the coverage_layer_district, upri_quezon_city_floodhazard_100yr, and ms_building_footprints_quezon_city layers and style them accordingly.

Layers loaded and styled

Layers loaded and styled

  1. Apply a nested/refined rule-based symbology on the flood hazard layer (upri_quezon_city_floodhazard_100yr) with the following filters.
    • Hazard Level
      hazard = attribute(@atlas_feature, 'hazard')
      • Low
        hazard = 'Low'
      • Moderate
        hazard = 'Moderate'
      • High
        hazard = 'High'
    • All
      attribute(@atlas_feature, 'hazard') = 'All'
      • Low
        hazard = 'Low'
      • Moderate
        hazard = 'Moderate'
      • High
        hazard = 'High'

Rule-based symbology for the flood hazard layer

Rule-based symbology for the flood hazard layer

  1. Create a new layout and add a map.
  2. Generate an atlas with the following configuration:
    • Coverage layer: coverage_layer_district
    • Page name and Sort by:
      "hazard" || ' - ' || "district"

Atlas configuration

Atlas configuration

Atlas configured

Atlas configured

  1. Enable the Atlas and look at the generated maps.

Sample atlas

Sample atlas

  1. Add other data defined elements such as titles and legends.

Atlas with other elements

Atlas with other element

You’ve learned how to use an atlas to map different areas showing the same layers as well as mapping the same layer multiple times in the same area. In this exercise, you will add another level to your Atlas skills by combining both—mapping multiple layers in multiple areas.

3.3. Mapping population density, flood hazard, building footprints, and roads for all districts in Quezon City

Section titled “3.3. Mapping population density, flood hazard, building footprints, and roads for all districts in Quezon City”
Level: Advanced

Output for 3.3. Mapping population density, flood hazard, building footprints, and roads for all districts in Quezon City

The goal of this exercise is for you to create at atlas that can map, per district:

  1. population density,
  2. flood hazard and building footprints,
  3. flood hazard and roads,
  4. flood hazard, building footprints, and roads.

In total, you will generate 24 maps (6 x 4) with 1 layout that can dynamically map different layers. imilar to the previous exercise, you need to be creative with your coverage layer. You will also utilize your knowledge of map themes.

To do this exercise, you need:

  • a coverage layer (coverage_layer_district_theme) that:
    • covers the extent of the 2nd District
    • has 24 features (1 for each map)
    • has a “theme” attribute/field corresponding to the theme that will be used for the map (atlas feature)
  • 4 map themes
    • popden: showing only the population density layer
    • flood_bldg: showing only the flood hazard and building footprint layers
    • flood_roads: showing only the flood hazard and roads layer
    • flood_all: showing the flood hazard, building footprint, and roads layers

Attribute table of the coverage layer

Attribute table of the coverage layer

  1. Load and style the following layers:
    • coverage_layer_district_theme,
    • upri_quezon_city_floodhazard_100yr,
    • ms_building_footprints_quezon_city,
    • osm_road layers,
    • adm_brgy_quezon_city_pop2000_2020 (style based on population density per 100000 sqm)

Layers loaded and styled

Layers loaded and styled

  1. Create 4 map themes with the following visible layers:
    • popden
      • adm_brgy_quezon_city_pop2000_2020 (population density layer)
    • flood_bldg
      • upri_quezon_city_floodhazard_100yr
      • ms_building_footprints_quezon_city
    • flood_roads
      • upri_quezon_city_floodhazard_100yr
      • osm_road layers
    • flood_all
      • upri_quezon_city_floodhazard_100yr
      • ms_building_footprints_quezon_city
      • osm_road layers

4 map themes created

4 map themes created

  1. Create a new layout and add a map.

Print Layout with map

Print Layout with map

  1. Generate an atlas with the following configuration:
    • Coverage layer: coverage_layer_district_themes
    • Page name and Sort by:
      "district" || ' - ' || "theme"

Atlas configuration (3)

Atlas configuration (3)

  1. In the Map’s Item Properties, under Layers, check Follow map theme and use a data-defined override so that the value for this parameter is theme (from the coverage layer attribute table). Use the following expression:
    attribute(@atlas_feature, 'theme')

Data-defined override of the Follow map theme property

Data-defined override of the Follow map theme property

  1. Preview the Atlas, did you do it right?

Atlas showing 24 maps

Atlas showing 24 maps]

  1. Let’s apply some of the things we learned from the previous exercises to improve the look and feel of the maps. We can:

Completed atlas

Completed atlas

Atlas that incorporates spatial and temporal elements

Section titled “Atlas that incorporates spatial and temporal elements”

3.4. Using an atlas to map earthquakes over time

Section titled “3.4. Using an atlas to map earthquakes over time”
Level: Advanced

See: Atlas that incorporates spatial and temporal elements.

Homework: Mapping health events in barangays per city/municipality in NCR

Section titled “Homework: Mapping health events in barangays per city/municipality in NCR”

Output for Homework

  1. Submit a geopackage containing the layers and project file.
  2. Submit the images generated by the atlas (store inside a zipped file).
  1. To save a project in a GeoPackage, go to Project ▶ Save to ▶ GeoPackage in the Menu bar and select the GeoPackage where you want to save your project to.
  2. Use map themes to control what’s visible in different maps (e.g. inset, main map).
  3. Use expressions to show only the barangays that are inside the current city/municipality (or atlas feature).
  4. Remember that you can duplicate the same layer and style it differently.
  1. To utilize the QGIS Atlas to create a layout that can generate a map of per-barangay health events for each city/municipality in the NCR.
  • Found inside the bnhr_qgis-architects-planners-urban-003.gpkg.
    • barangays - vector file of the barangays in the NCR with a field for the number of health_events per barangay
  1. Create a municities layer from the barangays layer. This will serve as your coverage layer. It would be good if you can add fields for the total number of health events and total number of barangays in the municitieslayer you will create.
  2. Use the QGIS Atlas functionality to create maps for each city/municipality in the NCR that will show the following:
    1. Map of the number of health events per barangay in the city/municipality.
    2. An inset map showing the relative location of the city/municipality being mapped.
    3. The name of the city/municipality and the total number of health events in the city/municipality
    4. The top 5 barangays with the most health events in the city/municipality
    5. A graph/plot of the number of health events per barangay in the city/municipality

Example map for San Juan

Example map for Pateros

Example map for Pasig City

Example map for Taguig

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