QGIS-A01: QGIS Atlas 3.28
QGIS Atlas
Introduction
Atlas is a component of Print Layouts which allows multiple output pages to be automatically generated from a single Layout, driven by an attribute of the data, with a page for each feature. This is commonly used to produce, for example, a single map for each feature in an administrative boundary layer, for example wards or counties.
Various settings are available, and as well as the map itself being dynamic, other items in the Layout such as titles can be dynamically generated, with attribute values drawn from the current feature.
Set up the Map
Open the QGIS project ...\Advanced\Atlasgeneration
There are three layers
nat_parks_england
railway_naptan
OS Opendata WMS
The task is to create an Atlas with one page for each National Park, displaying all the data available, with some appropriate styling.
Make any changes you need to the styling
Add and style any other layers you would like to see on the map
Set up the Atlas
To do this, first create a layout and enable an Atlas:
Go to Project > New Print Layout
Enter an appropriate name
Add a map, legend, scalebar and label
Go to Atlas > Atlas Settings, and complete the dialogue below, setting the Coverage layer to the national parks layer
Limit the number of features in the Atlas to save export time, by using the Filter with option - export only those parks which are smaller than 1,000 sq km (1,000 million sq m).
Make sure you uncheck Single file export when possible, so you get a PDF for each feature:
You now need to configure the map which is going to be used for the Atlas (bear in mind that you might have more than one map). Select the map, navigate to the Item properties tab and complete the Controlled by Atlas section:
Note that you will need to decide at this point whether to show each feature at the same scale or whether you want each feature to use the maximum area of the page, which will usually mean a range of scales - try with both options.
Review the results
You are now ready to have a look at the Atlas - use the Atlas toolbar controls to review the maps - first click on Preview Atlas (the right-hand button on the Atlas toolbar) to activate the tools.
Use the left and right arrows to scroll through the Atlas pages. You can now see what each page of the Atlas will look like when generated. Make any changes you need to the styling or Atlas setting and review again until you are happy that the outcome is ready for publication.
Filter the Atlas
If you only want to show a subset of the features in the Atlas, you can filter the data in the Altas settings. For example to show only parks with an area of less then 1,000 sqm, add a filter in the Atlas properties page:
|
Add further elements
In the label box, use Insert/Edit Expression to add a dynamic title to the map pages - so that the result is something like:
Map of Lake District National Park: map 3 of 10
Note that you will need to use attribute with the name of the national park, as well as atlas_featurenumber and atlas_totalfeatures, to produce this result - search for these in the Expression Builder dialogue.Add any other features to the map you think might be useful, and any other fields or variables.
Review the updated output pages in the preview.
Change the scale settings for the map (as shown in the second screenshot in Set up the Atlas above), and review the results.
When you have created an Atlas which is ready to produce, export the results.
Go to Atlas > Export Atlas as PDF
Follow the prompts, and create a new folder under ...\QGIS Training\Advanced and set a file name
Generate the PDF - it will take a little while to generate, but you can view each PDF as it's generated
Open the PDF output and review, then revise and regenerate the output if necessary.
Customise the filename for each PDF by editing the Output filename expression value under Atlas using the expression builder, to use an attribute value from the feature in the filename (for example the national park name).
Use a hidden layer
You can use a coverage layer which is not visible in the map to drive the Atlas - check the Hidden coverage layer box to do this.
This could be a grid layer for example, or a layer with polygons for specific areas of interest. If you have time, try using this approach, creating an appropriate layer.
Set styling to highlight the layer in focus
You may want your styling to differentiate between the feature which is the focus of the map, and the other features, so that it stands out when there is more than one feature visible in the map - for example when you are looking at the New Forest National Park, when the data is not filtered..
To do this, you will need to add a rule-based style for every layer which you want to change.
In the Symbology tab for the layer:
Select Rule-based from the style drop-down at the top
Click the + button at the bottom of the dialog to add a new rule
Expand the Edit Rule dialog so you can see all the controls
Enter 'Feature in focus' for the Label, to remind you that this new rule will only apply to the current Atlas feature
Open the expression builder dialog, and in the search box enter 'id'
Use the results to create the expression $id = @atlas_featureid - this will apply the style in the rule only to the current Atlas feature
Set the styling for this rule, and for the other default rule as you wish - for example you may want to change colours and transparency
Preview the Atlas pages in the Print Layout to see the results - to compare the feature in focus with other adjacent features (parks), you will need to take off the filter in the Atlas properties
If you want to make the styling of features other than those in the coverage layer dynamic, you'll need to use a rule-based style with an expression which determines, for example whether they are inside the current feature:
|
Try editing the symbology of the railway stations layer to change the style of the station depending on whether they are inside or outside the current national park.
You may also want to use other Geometry functions such as intersects, or overlaps.

