14.6. Lesson: Creating Detailed Maps with the Atlas Tool

The systematic sampling design is ready and the field teams have loaded the GPS coordinates in their navigation devices. They also have a field data form where they will collect the information measured at every sample plot. To easier find their way to every sample plot, they have requested a number of detail maps where some ground information can be clearly seen along with a smaller subset of sample plots and some information about the map area. You can use the Atlas tool to automatically generate a number of maps with a common format.

The goal for this lesson: Learn to use the Atlas tool in QGIS to generate detailed printable maps to assist in the field inventory work.

14.6.1. basic Follow Along: Preparing the Print Layout

Before we can automate the detailed maps of the forest area and our sampling plots, we need to create a map template with all the elements we consider useful for the field work. Of course the most important will be a properly styled but, as you have seen before, you will also need to add lots of other elements that complete the printed map.

  1. Open the QGIS project from the previous lesson forest_inventory.qgs. You should have at least the following layers:

    • forest_stands_2012 (with a 50% transparency, green fill and darker green border lines)

    • systematic_plots_clip

    • rautjarvi_aerial

  2. Save the project with a new name, map_creation.qgs.

To create a printable map, remember that you use the Layout Manager:

  1. Open Project ► layoutManager Layout Manager….

  2. In the Layout manager dialog:

    1. Under New from template, press the Create… button next to the Empty layout entry

    2. Name your print layout forest_map.

    3. Press OK. A new print layout is created and opened, showing a blank paper.

  3. In the print Layout window, ensure properties are set for an A4 paper:

    1. Right-click over the paper and select Page properties. The Page properties panel is open on the right side of the layout.

    2. Check Size is A4.

    3. Check Orientation is Landscape.

  4. Enable the Layout tab next to the Page properties panel and set Export resolution to 300 dpi.

Composing a map is easier if you make use of the canvas grid to position the different elements. Review the settings for the layout grid:

  1. In the Layout tab expand the Guides and Grid region.

  2. Check that Grid spacing is set to 10 mm and that Snap tolerance is set to 5 px.

You need to activate the use of the grid:

  1. Open the View menu.

  2. Check Show grid.

  3. Check Snap to grid.

  4. Notice that options for using Guides are checked by default, which allows you to see guiding lines when you are moving elements in the layout.

  5. Now you can start to add elements to your layout. Add first a map element so you can review how the map canvas looks as you will be making changes in the layers symbology:

    1. Click on the addMap Add Map button.

    2. Click and drag a box on the canvas so that the map occupies most of it.

    ../../../_images/composer_1.png

Notice how the mouse cursor snaps to the canvas grid. Use this function when you add other elements. If you want to have more accuracy, change the grid Spacing setting. If for some reason you don’t want to snap to the grid at some point, you can always check or uncheck it in the View menu.

14.6.2. basic Follow Along: Adding Background Map

Leave the layout open but go back to the map. Let’s add some background data and create some styling so that the map content is as clear as possible.

  1. Add the background raster basic_map.tif that you can find in the exercise_data\forestry\ folder.

  2. If prompted select the ETRS89 / ETRS-TM35FIN CRS for the raster.

    As you can see the background map is already styled. This type of ready to use cartography raster is very common. It is created from vector data, styled in a standard format and stored as a raster so that you don’t have to bother styling several vector layers and worrying about getting a good result.

  3. Now zoom to your sample plots, so that you can see only about four or five lines of plots.

The current styling of the sample plots is not the best:

../../../_images/plots_zoom1-2.png

While during the last exercises, the white buffer was OK on top of the aerial image, now that the background image is mostly white you barely can see the labels. But how does it look in the print layout? Let’s check it:

  1. Go to the print layout window.

  2. Use the select Select/Move item button to select the map element in the layout.

  3. Go to the Item properties tab.

  4. Click on setToCanvasExtent Set map extent to match main canvas extent.

  5. If you need to refresh the element, click on refresh Update map preview.

Obviously this is not good enough; you want to make the plot numbers as clearly visible as possible for the field teams.

14.6.3. basic Try Yourself Changing the Symbology of the Layers

You have been working in Module: Egyszerű térkép létrehozása és felfedezése with symbology and in Module: Vektoros adatok osztályozása with labeling. Go back to those modules if you need to refresh about some of the available options and tools. Your goal is to get the plots locations and their name to be as clearly visible as possible but always allowing to see the background map elements. You can take some guidance from this image:

../../../_images/plots_zoom2_symbology.png

You will use later the the green styling of the forest_stands_2012 layer. In order to keep it, and have a visualization of it that shows only the stand borders:

  1. Right click on forest_stands_2012 and select Duplicate

  2. You get a new layer named forest_stands_2012 copy that you can use to define a different style, for example with no filling and red borders.

    Now you have two different visualizations of the forest stands and you can decide which one to display for your detail map.

  3. Go back to the print layout window often to see what the map would look like. For the purposes of creating detailed maps, you are looking for a symbology that looks good not at the scale of the whole forest area (left image below) but at a closer scale (right image below). Remember to use refresh Update map preview and setToCanvasExtent Set map extent to match main canvas extent whenever you change the zoom in your map or the layout.

    ../../../_images/composer_2-3.png

14.6.4. basic Try Yourself Create a Basic Map Template

  1. Once you have a symbology you are happy with, you are ready to add some more information to your printed map. Add at least the following elements:

    • Title.

    • A scale bar.

    • Grid frame for your map.

    • Coordinates on the sides of the grid.

  2. You have created a similar layout already in Module: Térképelrendezések. Go back to that module as you need. You can look at this example image for reference:

    ../../../_images/map_template1.png
  3. Export your map as an image and look at it.

    1. Layout ► Export as Image….

    2. Use for example the JPG format.

That is what it will look like when printed.

14.6.5. basic Follow Along: Adding More Elements to the Print Layout

As you probably noticed in the suggested map template images, there are plenty of room on the right side of the canvas. Lets see what else could go in there. For the purposes of our map, a legend is not really necessary, but an overview map and some text boxes could add value to the map.

The overview map will help the field teams place the detail map inside the general forest area:

  1. Add another map element to the canvas, right under the title text.

  2. In the Item properties tab, open the Overview dropdown.

  3. Set the Overview frame to Map 0. This creates a shadowed rectangle over the smaller map representing the extent visible in the bigger map.

  4. Check also the Frame option with a black color and a Thickness of 0.30.

../../../_images/more_elements1.png

Notice that your overview map is not really giving an overview of the forest area which is what you want. You want this map to represent the whole forest area and you want it to show only the background map and the forest_stands_2012 layer, and not display the sample plots. And also you want to lock its view so it does not change anymore whenever you change the visibility or order of the layers.

  1. Go back to the map, but don’t close the Print Layout.

  2. Right click the forest_stands_2012 layer and click on Zoom to Layer Extent.

  3. Deactivate all layers except for basic_map and forest_stands_2012.

  4. Expand the Manage map themes tool on the Layers panel and select Add theme.

  5. Name it basic_overview.

  6. Go back to the print layout.

  7. With the small map selected, click the Set map extent to match main canvas extent to set its extents to what you can see in the map window.

  8. Lock the view for the overview map by checking Follow map theme and selecting basic_overview under Main properties.

Now your overview map is more what you expected and its view will not change anymore. But, of course, now your detail map is not showing anymore the stand borders nor the sample plots. Let’s fix that:

  1. Go to the map window again and select the layers you want to be visible (systematic_plots_clip, forest_stands_2012 copy and Basic_map).

  2. Zoom again to have only a few lines of sample plots visible.

  3. Go back to the Print Layout window.

  4. Select the bigger map in your layout.

  5. In Item properties click on Update preview and Set map extent to match main canvas extent.

Notice that only the bigger map is displaying the current map view, and the small overview map is keeping the same view you had when you locked it.

Note also that the overview is showing a shaded frame for the extent shown in the detail map.

../../../_images/more_elements2.png

Your template map is almost ready. Add now two text boxes below the map, one containing the text «Detailed map zone: « and the other one «Remarks: «. Place them as you can see in the image above.

You can also add a North arrow to the overview map:

  1. Select the northArrow Add North Arrow tool.

  2. Click and drag a rectangle at the upper right corner of the overview map.

  3. In Item properties Check SVG image

  4. Browse SVG Browser ► SVG Groups for an arrow image.

  5. Under Image rotation, check the Sync with map and select Map 1 (the overview map).

  6. Resize the arrow image to a size that looks good on the small map.

The basic map layout is ready, now you want to make use of the Atlas tool to generate as many detail maps in this format as you consider necessary.

14.6.6. basic Follow Along: Creating an Atlas Coverage

The Atlas coverage is just a vector layer that will be used to generate the detail maps, one map for every feature in the coverage. To get an idea of what you will do next, here is a full set of detail maps for the forest area:

../../../_images/preview_atlas_results.png

The coverage could be any existing layer, but usually it makes more sense to create one for the specific purpose. Let’s create a grid of polygons covering the forest area:

  1. In the QGIS map view, open Vector ► Research Tools ► vectorGrid Create grid.

  2. Set the tool as shown in this image:

    ../../../_images/coverage_polygons.png
  3. Save the output as atlas_coverage.shp.

  4. Style the new atlas_coverage layer so that the polygons have no filling.

The new polygons are covering the whole forest area and they give you an idea of what each map (created from each polygon) will contain.

../../../_images/atlas_coverage.png

14.6.7. basic Follow Along: Setting Up the Atlas Tool

The last step is to set up the Atlas tool:

  1. Go back to the print layout.

  2. In the panel on the right, go to the Atlas generation tab.

  3. Set the options as follows:

    ../../../_images/atlas_settings.png

    That tells the Atlas tool to use the features (polygons) inside atlas_coverage as the focus for every detail map. It will output one map for every feature in the layer. The Hidden coverage layer tells the Atlas to not show the polygons in the output maps.

One more thing needs to be done. You need to tell the Atlas tool what map element is going to be updated for every output map. By now, you probably can guess that the map to be changed for every feature is the one you have prepared to contain detail views of the sample plots, that is the bigger map element in your canvas:

  1. Select the bigger map element (Map 0).

  2. Go to the Item properties tab.

  3. In the list, check Controlled by atlas.

  4. And set the Marging around feature to 10%. The view extent will be 10% bigger than the polygons, which means that your detail maps will have a 10% overlap.

    ../../../_images/controlled_by_atlas.png

Now you can use the preview tool for Atlas maps to review what your maps will look like:

  1. Activate the Atlas previews using the button atlas or if your Atlas toolbar is not visible, via Atlas ► Preview Atlas.

  2. You can use the arrows in the Atlas tool bar or in the Atlas menu to move through maps that will be created.

Note that some of them cover areas that are not interesting. Let’s do something about it and save some trees by not printing those useless maps.

14.6.8. basic Follow Along: Editing the Coverage Layer

Besides removing the polygons for those areas that are not interesting, you can also customize the text labels in your map to be generated with content from the Attribute table of your coverage layer:

  1. Go back to the map view.

  2. Enable editing for the atlas_coverage layer.

  3. Select the polygons that are selected (in yellow) in the image below.

  4. Remove the selected polygons.

  5. Disable editing and save the edits.

../../../_images/remove_polygons.png

You can go back to the print layout and check that the previews of the Atlas use only the polygons you left in the layer.

The coverage layer you are using does not yet have useful information that you could use to customize the content of the labels in your map. The first step is to create them, you can add for example a zone code for the polygon areas and a field with some remarks for the field teams to have into account:

  1. Open the Attribute table for the atlas_coverage layer.

  2. Enable editing.

  3. Use the calculateField calculator to create and populate the following two fields.

  4. Create a field named Zone of type Whole number (integer).

  5. In the Expression box write/copy/construct $rownum.

  6. Create another field named Remarks, of type Text (string) and a width of 255.

  7. In the Expression box write 'No remarks.'. This will set all the default value for all the polygons.

The forest manager will have some information about the area that might be useful when visiting the area. For example, the existence of a bridge, a swamp or the location of a protected species. The atlas_coverage layer is probably in edit mode still, add the following text in the Remarks field to the corresponding polygons (double click the cell to edit it):

  • For the Zone 2: Bridge to the North of plot 19. Siberian squirrel between p_13 and p_14.

  • For the Zone 6: Difficult to transit in swamp to the North of the lake.`

  • For the Zone 7: Siberian squirrel to the South East of p_94.

  • Disable editing and save your edits.

Almost ready, now you have to tell the Atlas tool that you want some of the text labels to use the information from the atlas_coverage layer’s attribute table.

  1. Go back to the Print Layout.

  2. Select the text label containing Detailed map....

  3. Set the Font size to 12.

  4. Set the cursor at the end of the text in the label.

  5. In the Item properties tab, inside the Main properties click on Insert or Edit an Expression….

  6. In the Function list double-click on the field Zone under Field and Values.

  7. Kattintson az OK gombra.

  8. The text inside the box in the Item properties should show Detail map inventory zone: [% "Zone" %]. Note that the [% "Zone" %] will be substituted by the value of the field Zone for the corresponding feature from the layer atlas_coverage.

  9. Test the contents of the label by looking at the different Atlas preview maps.

  10. Do the same for the labels with the text Remarks: using the field with the zone information. You can leave a break line before you enter the expression. You can see the result for the preview of zone 2 in the image below:

    ../../../_images/preview_zone2.png
  11. Use the Atlas preview to browse through all the maps you will be creating soon and enjoy!

14.6.9. basic Follow Along: Printing the Maps

Last but not least, printing or exporting your maps to image files or PDF files. You can use the Atlas ► Export Atlas as Images… or Atlas ► Export Atlas as PDF…. Currently the SVG export format is not working properly and will give a poor result.

Lets print the maps as a single PDF that you can send to the field office for printing:

  1. Go to the Atlas generation tab on the right panel.

  2. Under the Output check the Single file export when possible. This will put all the maps together into a PDF file, if this option is not checked you will get one file for every map.

  3. Open Layout ► Export as PDF….

  4. Save the PDF file as inventory_2012_maps.pdf in your exercise_data\forestry\samplig\map_creation\ folder.

  5. Open the PDF file to check that everything went as expected.

  6. You could just as easily create separate images for every map (remember to uncheck the single file creation), here you can see the thumbnails of the images that would be created:

    ../../../_images/maps_as_images.png
  7. In the Print Layout, press fileSave Save in order to save your print layout changes in the project. This also saves the project file. You can reopen the project at any time and run or edit the atlas.

    It is also possible to save your map as a layout template as forestry_atlas.qpt in your exercise_data\forestry\map_creation\ folder. Use Layout ► Save as Template. You will be able to use this template again and again in other projects.

  8. Close the Print Layout and the project.

14.6.10. In Conclusion

You have managed to create a template map that can be used to automatically generate detail maps to be used in the field to help navigate to the different plots. As you noticed, this was not an easy task but the benefit will come when you need to create similar maps for other regions and you can use the template you just saved.

14.6.11. What’s Next?

In the next lesson, you will see how you can use LiDAR data to create a DEM and then use it to enhance your data and maps visibility.