I was wondering if it is possible in QGIS 3.2 to cycle through different layers.
For example, I have a workspace open with 3 raster layers (A, B and C). I would like to create 3 maps:
- Map A with Layer A and Legend A
- Map B with Layer B and Legend B
- Map C with Layer C and Legend C
The only difference in all these maps is the switching of the raster layer and the legend of the layer. Everything else is the same.
I found a similar question before but it appears to be unanswered.
Best Answer
You can set layer visibility (in the layer symbology) based on an atlas variable. Your options for atlas variables are: @atlas_feature, @atlas_featureid, @atlas_geometry and @atlas_pagename.
In QGIS 3.0, use the atlas variable to control whether the layer is enabled.
For example, if your atlas pages are named Map A, Map B and Map C, set the visibility of the grid for Map A like so:
In QGIS 2.18 and earlier, "Enable layer" is not an option. Instead, use a similar method to control the layer transparency. Use this expression for data-defined transparency for Map A:
You can also write your own expressions to control layer visibility within the print composer.
Write an expression that outputs a list of map layer names separated by the | character. For example:
This is how I knew how to format the list of map layer names.