How to use QGIS Atlas with multiple layers/files per coverage?

Since QGIS 2.12, with the introduction of data-defined properties on the "lock layers for map" option, in the map item properties, you can do what you seek. You just need to create the right coverage layer, with the information of the extents, but also of the layers to "print".

Create the layer presets

You can "save" the current state (visible or not visible) of your layers as presets. Just create the desired combination and press the eye icon on the layers panel, and choose "add preset".

Basically, you will have to create a preset for each contour, with that layer visible (paired with other layers if you like). This will be your "set of layers".

Give your preset memorable names, or else just opt for some kind of a sequence.

Creating the coverage layer.

Now you will have to create a polygon layer with all the possible combinations between the extents polygons, and all the presets. That means you will end up with some redundancy. You will have to replicate each extent polygon for each preset. Something like this:

polygon 1, preset a polygon 1, preset b ... polygon 50, preset a polygon 50, preset b

You can do this manually with copy paste, or else create some kind of script, but I would say your best and easier way would be using Spatialite or Postgis database. Just import you polygons extents there, and create a new non-spatial table with all presets names. Then, create a view that returns all the combinations.

SELECT f.*, g.preset_name
FROM polygons_extent as f, presets as g

Making it work

Add the new layer or view to QGIS, use it as coverage layer in atlas settings, and use the preset_name attribute in data-defined properties on the "lock layers for map" option.


You need a loop in a loop, this is not an out of the box possibility in the QGIS Print Composer without a Python script, or some manually repetition in the Print Composer.

The manually way could be using 30 pages in one composer. This is set on the composition tab. If you use a alignment line (the red one), you could place the maps aligned. For each map you have to 'Lock layers for map item' for the one contour you want for the map. This will give you 30 maps in one PDF. You will just have to setup the Atlas coverage loop for one of the maps.

This may be too much manually work for one go, but if you need to print this setup several times, it may be worth a go.

map

Tags:

Qgis

Batch