Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (2024)

If your organization publishes printed or online maps, you often would need tocreate many maps with the same template - usually one for each administrativeunit or a region of interest. Creating these maps manually can take a long timeand if you want to update these on a regular basis, it can turn into a chore.QGIS has a tool called Atlas that can help you create a map template andeasily publish a large number of maps for different geographic regions. If youare not familiar with the basics of Print Layout, please go through theMaking a Map tutorial.

Overview of the task

This tutorial shows how to create wetlands map for each county in the state ofHawaii.

Other skills you will learn

  • Using Inverted Polygons style renderer to fill areas outside of polygons.

  • Write an expression in the Rule Based style renderer to show onlythe current feature in Atlas.

  • Write an expression to create dynamic labels in Print Layout.

  • Using Shapeburst fill style renderer to create a dual-tone polygon fill.

Get the data

We will use the GIS Data Layers from State of Hawaii -Office of Planning

Download the Wetlands layer fromBiologic and Ecologic category.

Download the Census County Boundaries 2010 layer from theCultural and Demographic category.

For convenience, you may directly download a copy of both the datasets from the linksbelow:

HI_Wetlands.shp.zip

county10.shp.zip

Data Source [HAWAII]

Procedure

  1. Locate the HI_Wetlands.shp.zip file in the QGIS Browser and expand it. Select the HI_Wetlands_Poly.shp file and drag it to the canvas. This layer contains polygons representing wetlands in the entire state of Hawaii.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (1)
  1. Since we want to make separate wetlands map for each county in the state, we will need the county boundaries layer. Browse to the county10.shp.zip file and expand it. Select the county10.shp file and drag it to the canvas.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (2)
  1. Turn off the visibility of the HI_Wetlands_Poly layer temporarily. You will see the polygons from the county10 layer clearly now. There are 5 features contained in this layer, with each feature having 1 or more polygons associated with it. The features represent 5 counties. We will use this layer as the coverage layer and configure QGIS to create 5 separate maps - one for each feature - automatically.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (3)
  1. Turn on the visibility of the HI_Wetlands_Poly layer. Go to Project ‣ New Print Layout...

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (4)
  1. Leave the print layout title empty and click OK.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (5)
  1. In the Print Layout window, go to Layout ‣ Add Map.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (6)
  1. Drag a rectangle while holding the left mouse button where you would like to insert the map.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (7)
  1. In QGIS3, the Atlas tab is not visible by default. Select View ‣ Panels ‣ Atlas.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (8)
  1. Switch to the Atlas tab. Check the Generate an atlas box.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (9)
  1. Select the county10 as the Coverage layer. This will indicate that we want to create 1 map each for every polygon feature in the county10 layer. You can also check the Hidden coverage layer so that the features themselves will not appear on the map.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (10)
  1. Switch to the Item Properties tab. Scroll down and check the Controlled by atlas box. This will indicate the layout that the content of the map displayed in this item will be determined by the Atlas tool.

Note

You must enable the Generare an atlas box in the Atlas tab, otherwise the Controlled by atlas checkbox will be diasbled.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (11)
  1. Now that you have configuring the Atlas settings, go to Atlas ‣ Preview Atlas.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (12)
  1. You will see the map refresh and show how individual map will look like. You can preview how the map will look for each of the county polygons. Go to Atlas ‣ Next Feature. Atlas will render the map to the extent of the next feature in the coverage layer.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (13)
  1. Let’s add a label to the map. Go to Layout ‣ Add Label.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (14)
  1. Under the Item properties tab, locate the Main properties section and click Insert an Expression… button.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (15)
  1. The label of the map can use the attributes from the coverage layer. The concat function is used to join multiple text items into a single text item. In this case we will join the value of the NAME10 attribute of the county10 layer with the text County of. Add an expression like below and click OK.

concat('County of ', "NAME10")
Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (16)
  1. Delete the leading Lorem ipsum placeholder text so that the textbox contains only the expression. Scroll down to the Appearance section and click on the Font dropdown. Choose the font and adjust the size to your liking.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (17)
  1. Choose Center as the Horizontal alignment and Middle as the Vertical alignment option.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (18)
  1. Add another label and enter Wetlands Map under the Main properties. Since there is no expression here, this text will remain the same on all maps.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (19)
  1. Go to Atlas ‣ Last Feature and verify that the map labels do work as intended. You will notice that the wetland map has polygons extending out in the ocean that looks ugly. We can change the style to that areas outside the county boundaries are hidden.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (20)
  1. Switch to the main QGIS window. Right-click the county10 layer and select Properties.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (21)
  1. In the Symbology tab, select the Inverted polygons renderer. This renderer styles the outside of the polygon - not inside. Select white as the fill color and click OK.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (22)
  1. You will notice that the polygons extending outside of the county boundaries are now disappeared. In reality, they are hidden by the white color fill extending out from the county polygons because of the Inverted polygons style.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (23)
  1. Switch to the Layout window. If we want the effect of the inverted polygons to show, we need to uncheck the Hidden coverage layer box under Atlas tab. Once unchecked, the rendered image will appear clean and areas outside the coverage polygon is not visible.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (24)
  1. There is one more problem though. You will notice that in some cases, parts of the map that are outside the coverage layer boundary are still visible. This is because Atlas doesn’t automatically hide other features. This can be useful in some cases, but for our purpose, we only want to show wetlands of the county whose map is being generated. To fix this, switch back to the main QGIS window and right-click the county10 layer and select Properties.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (25)
  1. In the Symbology tab, select Rule-based as the Sub renderer. Double-click the area under Rule.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (26)
  1. In the Edit rule dialog, click the Expression button next to Filter.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (27)
  1. In the Expression string builder, expand the Variables group of functions. The @atlas_featureid variable stores the id of the the currently selected feature. We will construct an expression that will select only the currently selected Atlas feature. Enter the expression as below and click OK.

$id = @atlas_featureid
Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (28)
  1. Close all intermediate dialogs and switch back to the Layout window. Select Map 1 item and click the Update preview button under Item properties tab to see the changes. Notice that now only the area covering the county boundary is shown.

Note

If you do not see the Update preview button, it may help to select another Item element first and then select Map 1 again.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (29)
  1. We will now add another dynamic label to show the current date. Go to Layout ‣ Add Label and select the area on the map. Click Insert an expression button.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (30)
  1. Expand the Date and Time functions group and you will find the $now function. This holds the current system time. The function todate() will convert this to a date string. Enter the expression as below and click OK.

concat('Created on: ', todate($now))
Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (31)
  1. Add another label citing the data source. You may also add other map elements such as a north arrow, scalebar etc. as described in Making a Map tutorial.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (32)
  1. We will make one last styling improvement. Switch back to the main QGIS window and right-click the HI_Wetlands_Poly layer and select Properties.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (33)
  1. In the Symbology tab, click on Simple fill and select Shapeburst fill as the Symbol layer type. Choose the Two color option and select shades of green and blue that you like. Click OK.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (34)
  1. Select Map 1 item and click the Update preview button under Item properties tab to see the changes.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (35)
  1. Once you are satisfied with the map layout and styling, go to Atlas ‣ Export Atlas as Images.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (36)
  1. Select a directory on your computer and click Choose.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (37)
  1. Leave the default options in the Image Export Options and click Save.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (38)
  1. The Atlas tool will now iterate through each feature in the coverage layer and create a separate map image based on the template we created. You can see the images in the directory once the process completes.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (39)
  1. Here are the map images for refeence.

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (40)Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (41)Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (42)Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (43)Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (44)

If you want to give feedback or share your experience with this tutorial, please comment below. (requires GitHub account)

Automating Map Creation with Print Layout Atlas (QGIS3) — QGIS Tutorials and Tips (2024)

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Kieth Sipes

Last Updated:

Views: 5827

Rating: 4.7 / 5 (47 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Kieth Sipes

Birthday: 2001-04-14

Address: Suite 492 62479 Champlin Loop, South Catrice, MS 57271

Phone: +9663362133320

Job: District Sales Analyst

Hobby: Digital arts, Dance, Ghost hunting, Worldbuilding, Kayaking, Table tennis, 3D printing

Introduction: My name is Kieth Sipes, I am a zany, rich, courageous, powerful, faithful, jolly, excited person who loves writing and wants to share my knowledge and understanding with you.