Video - Semi-Automated Mapping in QGIS with the Atlas Panel

Catalogue number: Catalogue number: 89200005

Issue number: 2020016

Release date: November 24, 2020

QGIS Demo 16

Semi-Automated Mapping in QGIS with the Atlas Panel - Video transcript

(The Statistics Canada symbol and Canada wordmark appear on screen with the title: "Semi-Automated Mapping in QGIS with the Atlas Panel")

So following up from Creating Maps in QGIS, today we'll discuss using the Atlas Panel in the Print Layout to rapidly generate multiple maps. The Atlas panel uses a specified 'Coverage Layer' to define the geographies of the outputs. Today we'll use it to map population dynamics in Census Metropolitan Areas - or CMAs for short - across Canada - effectively semi-automating the map production process.

So once again the preparation steps are provided in the video description – but to summarize quickly, we used the one-to-one join procedures to link the population table to the Census Tract layer. The Refactor Fields tool was then applied to save to a permanent file with correctly attributed field types. We also dissolved the Census Tract layer using the Census Metropolitan Area Name (CMANAME) field to create the Coverage Layer for our Atlas, and with the fill colour set to fully transparent, outline the Census Tracts within our main map group.

The cartographic Census Subdivision layer was then run through the Fix Geometries tool, dissolved by the Provincial Unique Identifier and run through the Multipart to Single Part tool, ensuring that all features were separate entries within the attribute table. Area fields were added to it, and the Lakes and Rivers polygon, using the Field Calculator, and the Select by Expression tool used to subset features with areas greater than 2500 and 500 square kilometres respectively and grouped together to comprise our Inset Map.

The Labels applied to our coverage and province layers had similar settings. So to quickly summarize - in the Formatting subtab for the coverage Layer we specified to wrap text on the dash character. A text buffer was also applied – with the coverage layer set to 75% Opacity. The Placement was set to Horizontal (slow) ensuring the legibility of the text-based labels. And in the Rendering tab only draw labels which fit completely within the feature was checked and discourage labels from covering the feature's boundaries was selected with the highest weight applied. So now we can toggle off the Prep Layers group.

Now in the Print Layout I used the add shapes tool, specifically Add Rectangles, to divide the layout for the map items, which were then locked within the Items panel. The alignment tool on the Actions toolbar was then used to ensure that added items were placed above the rectangles. I've also already added many of the mandatory map items – including the additional information, scale bar, legend and title. The title uses an expression, including a generic text prefix within single quotes followed by the vertical separators and then Census Metropolitan Area name field to label by metropolitan area, which will update automatically once our Atlas is generated.

Just a quick tip for map item formatting - if greater control was needed – the Print Screen or Snipping tools could be used to export, externally format and re-add items, such as the legend, diagrams or table, as a picture.

On that note our North Arrow is still missing. So rather than using the add Arrow and Text label function, let's add it from Picture this time. Clicking and dragging across the desired location in the Print Layout, we can then go to the Item Properties Panel and expand the Search Directories. And once loaded select the desired icon. I'll alter the Fill Colour to be darker, to ensure its visibility against the main map, and then clicking Back, we'll also switch the placement to Middle.

So now we can add both maps simultaneously – placing the main map in the larger box of the layout and the inset map in the smaller box on the right. The main map is currently being rendered over our north arrow, so once again we'll select it and use the Lower in the Alignment tools to ensure the north arrow is visible.

While they're rendering I'd also like to highlight that the scale-bar for the main map is set to Fit Segment Width as opposed to the Fixed Width used in the previous demo, which will update the scale-bar according to the size of the census metropolitan area being mapped.

Now for our second map, let's add a Grid, expanding the drop-down and clicking the Plus icon – and then select Modify Grid Properties. We'll also change the CRS to WGS 84, entering 4326 in the system selector, so that we can show coordinates in decimal degrees. We'll specify an interval of 2 degrees, which at the moment adds many lines, but will be more appropriate once we generate the Atlas. Check the Draw Coordinates button. The format of the coordinates can then be selected in the drop-down, here we'll leave it with the default. We'll specify to show latitude only for the Right and Left parameters and longitude only for the Bottom and Top. At the bottom of the panel we'll change the precision for the Grid units to 1.

Back in the Item Properties Panel for the Inset Map, we'll also add an Overview – clicking the plus icon and specifying the map being overviewed in the drop-down, which is Map 1.

Now we can generate the Atlas. So in the Atlas drop-down on the Menu-bar select Atlas Settings. And within the Atlas panel check Generate Atlas and specify the Coverage Layer – in this case DCMAAtlas or the dissolved Census Metropolitan Areas. We'll specify the field used for the Page Name, in this case the CMANAME field and use the same field for Sort by. This will sort them alphabetically when we preview our Atlas. Uncheck the Single Export option, as we want each metropolitan area to be a separate map and select the desired output file format. Additionally we'll change the output filename to something more intuitive than just the feature IDs. So we'll switch 'Output' to JCTPop and then click on the Expression box. In the Variables drop-down, we will replace featureID with @atlas_pagename, which we set to CMANAME field, so the outputs will be named according to the census metropolitan area. This did involve a trade-off– requiring the entries within the CMANAME field to be reformatted – removing periods, slashes, question marks and other symbols that caused erroneous filenames, which would lead to the atlas output failing. So having replaced these characters I can just click OK.

Now we can Select Map 1 and within the Item properties Panel check the Controlled by Atlas box. For the main map we'll specify 5% for the Margins Around the Feature. In the main interface we can now toggle off the inset map group. And back in the Print Layout select the main map and in the Item Properties Panel check Lock Layers and Lock Styles.

Repeating with Map 2, we'll check controlled by Atlas once again and enter a larger margin of 750% to ensure the broader geographic location is shown. Then in the main interface toggle off the main map group and back in the layout select Lock Layers. And this is so that the inset map does not show the layers of the main map and vice versa.

Now on the Atlas toolbar we can select the Preview Atlas icon. So we can toggle through the different CMAs alphabetically, or select ones of interest from the drop-down. The next metropolitan area is Barrie. So as you can see, the title, grid and scale-bar update rapidly, while the maps, particularly the Inset Map takes longer. This is likely due to the detail of the cartographic boundary file, combined with the broader extent being mapped within the inset.

I ran the Atlas output earlier – as we can see scrolling through the maps, most are appropriately formatted and ready for use as supporting figures or stand-alone documents. Relatively few maps require manual editing and individual export to maintain intuitive values for map items such as the scale or grid intervals. For example, for Edmonton we would want to use a larger interval for the Grid coordinates, such as 5°. And similarly, for Granby, we would want to alter the scale to Fixed Width and enter 10 for a more intuitive break value. Then we could use the export procedures from the making maps demo to individually export these specific maps. On the whole, the Atlas Panel has facilitated rapidly mapping multiple locations and variations in attributes of interest with relatively little input or effort.

Toggling back we could now select another CMA of interest, such as Drummondville – or one of the outputs from the Atlas that needed edits such as Edmonton. Then we could select the Inset map, re-expand the Grids drop-down and click the Modify button – updating the Grid Interval for X to 5 degrees. We could then resize the North Arrow to ensure it's not obscuring the main map features, and then individually export this map using the procedures covered in the previous demo.

So with the Export Atlas tool we can specify the for..file format to use. The same formats from the single export options are available. It is a good idea to create a separate directory for the output maps. Then specify the output resolution and click Save to run. We won't actually run the output as it's a time-intensive process, taking around 35 minutes.

The last thing that we would want to do is save the print layout as a template for further use, such as reapplying for map production in the next census collection period or to generate maps with a different variable of interest at the Census Tract level.

So use the Atlas panel with a coverage layer to rapidly and easily generate multiple maps for particular areas of interest. Save the template for re-use in examining other variables of interest or applying in another time-period. Apply these skills to your own areas of expertise and datasets of interest for semi-automated map production.

(The words: "For comments or questions about this video, GIS tools or other Statistics Canada products or services, please contact us: statcan.sisagrequestssrsrequetesag.statcan@canada.ca" appear on screen.)

(Canada wordmark appears.)