Following our involvement into the QGIS open source community, we are now pleased to inform you the Atlas plugin has been integrated into a core functionality of the QGIS print composer !
This work has been done thanks to financial support mainly from :
Other financial contributors :
- John C Tull
- Bill Williamson
- Ujaval Gandhi
Here is a tutorial on how to use the new atlas generation functionality. You should have a version of the development branch that is dated after 10-6-2012 (date of the QGIS Hackfest) for it to be included.
The print composer includes generation functions that allow to create map books, or series of maps, in an automated way. The concept is to use a coverage layer, which contains geometries and fields. For each geometry in the coverage layer, a new output will be generated where the content of some canvas maps will be moved to highlight the current geometry.
It is also now possible to replace text labels set up in the composer, with coverage layer’s attribute values, enabling you to set a title, comment, document name, page number, or any dynamic information you want to display on your final maps.
Let’s see the steps needed to create a map book.
Create a project
Let us begin with a classic QGIS project, import our layers and set styles according to our needs.
We have to create a layer containing coverage geometries, which can be any type of geometries, even if polygons are best to represent a coverage. This will be read by the atlas generator and for each feature of the layer, an output map will be created.
This coverage can have any field number and names. Here, we took a squared 3×3 grid that corresponds to delimiting zones with a special name.
We can now create a template for our output, in the Quantum GIS composer. The template is a classic composer document. We have to remind which map item will contain our coverages. We can know the map item name with the tooltip (”Map 0” for example).
We will here create a simple layout with a central map object where each geometry will be displayed, a smaller map that will serve as an overview frame and two labels: one displaying the current zone name and another one displaying the current page number.
Expressions can now be inserted into labels. Fields of the coverage layer can then be used. This is much more powerful than the previous $FIELD() syntax.
Four new variables have been added:
- $feature and $numfeatures that give the current feature number and the total feature number of the coverage layer
- $page and $numpages that give the current page number, in case of a multi page layout. These variables do not vary with the number of atlas features.
So for instance, if we have a 2-page document with a coverage layer of 10 features, and want to export everything to a single file, the expression
[% $page + ( $feature - 1 ) * $numpages %]
would give the current “real” page number.
We are now ready to launch the generation, using the Atlas generation tab of the composer.
The available options are:
- Composer map : Item on the composer template where the map extent will be zoomed on each coverage. Use the tooltip over objects in the composer window to know the map item name
- Coverage layer : The name of the layer containing the coverage geometries
- Hidden coverage : If checked, the coverage layer itself will not be rendered on the output map
- Margin around coverage : Amount of space around given coverage geometry. Default is 10% of coverage bounding box
- Fixed scale : If checked, the composer map’s scale will not be changed for each geometry. It is up to the user to set its extent. The composer map’s will still be centered on each geometry of the coverage layer.
- Output filename expression : Generic name of the output files. Expressions can be used here.
- Single file export when possible : If checked, export will be done to a single file if possible. Until now, only PDF export supports this feature.
When all the options have been set, we can use the print / export features as before. These functionalities will be modified if an atlas generation has been configured.
For example, if we ask for an export to images, a dialog will ask us to select the output directory of the export as well as the output image format.
Atlas generation is supported for all rendering possibilities:
- PDF export (either a single file for each geometry or a single file for all the geometries)
- SVG export (one file for each page)
- Bitmap images (one file for each page)
Here is an example of what could be obtained when selecting the single-file export PDF :
What’s next ?
If you like this feature and want some improvement, do not hesitate to contact us, we can develop it for you, or adapt it to your specific needs !