QGIS Atlas – How to Filter Layers in QGIS Atlas

atlasfilterfmeqgis

In processing several spatial data sets (tbl_data_01, tbl_data_02, tbl_data_03, etc) using FME I establish a spatial table called "tbl_metadata" with information about each of the data set. This table holds the metadata (if available) and the layer name for each of the spatial data sets. A spatial object, a rectangular envelope, is also established.

I would like to use tbl_metadata to produce an atlas (a dataset fact sheet) in QGIS 3 for each of the spatial data sets. The atlas should present a map sheet showing each spatialdata set as well as a table with the available metadata. The spatial data sets have already been read in to the project.

I have read several presentations doing something similar. One is to use the coverage layer to highlight the current atlas feature using a conditional (@atlas_featureid = $id) or even selecting certain objects in a separate layer based on a feature name. An option could also be to define presets. But this latter method requires manual adjustments.

Is there a method to use the atlas table (here tbl_metadata) to filter/add the associated spatial data sets to respective maps in the atlas?

Best Answer

You can use the tbl_metadata file as coverage layer in Atlas. Then use rule-based symbology with @layer_name = @atlas_pagename.

I assume that your data looks like this (the attribute table is tbl_metadata table):

enter image description here

  1. Set the tbl_metadata as Coverage layer and select the field with dataset name as Page name. If you want to hide the coverage layer geometry, check Hidden coverage layer.

enter image description here

  1. In the map item Item Properties check Controlled by Atlas. This ensure that extent of features (rectangular envelope) will control the zoom of map item.

enter image description here

  1. Now you have to change symbology of each layer to Rule-based and add rule: @layer_name = @atlas_pagename, the layer than will be symbolised only if the layer name is equal to current atlas page name.

enter image description here

  1. Add attribute table item with enter image description here. Select tbl_metadata as a layer and set the filter to "dataset" = @atlas_pagename, this filter only the rows where value of dataset is equal to atlas page name.

enter image description here

  1. Run the atlas preview

enter image description here

Note: QGIS can read also .csv files as layer without geometry, which can be also used as coverage layer. In that case you can skip the step 2. The zoom will not be controlled by geometry and will be fixed (since it is table without geometry).