My problem is quite hard to explain, I have attached some images to help illustrate my issue.

I want to produce a large number of maps which overlap in geographic area. Currently my data is arranged as shown in image 1.

I have a number of sites in each column, which colour UK wards based on differing values.

I want to set up a system in QGIS which will map Site 1, and then move along the colons to map site 2 and so on.

Unfortunately each ward is affected by multiple sites. Ward E050001 may have a value for site 1 of 0.75, and then a value of 0.25 for site 2 etc.

I currently manually change the values to move along the columns in the layer properties as shown in image 2, and it's this manual step that prevents me from using a QGIS Atlas.

If Image 3 was my map, I'd like it to display the area around site 1, export a map, and then move on to site 2 and export a map. This is a simplification however, as the areas often overlap for sites, and I'd like the colour to vary based on the value in the cells shown in image one.

I feel the best way would be to use an Atlas and a bit of python to move each column along as it moves to the next item in the Atlas, but an unsure how to do this or if it would even work.

Does anybody have any idea how I would go about achieving this?

It's trivial to do manually, but I have potentially thousands of maps that I need to do!

enter image description here

enter image description here

enter image description here

  • What do you mean by "move each column along as it moves to the next item in the Atlas?" Are you trying to display the attribute table in the print composer, and display different columns for each map?
    – csk
    Nov 30, 2017 at 20:07
  • 1
    Is there any way to structure the data into just 4 columns: WD114CD, Spacer, SiteNumber, Value. The table would have ~20 times as many rows based on what you show, but would be easier to group for iterating. Cross-tabbed data can be difficult to automate. Dec 1, 2017 at 0:32
  • I had tried that, but unfortunately each geographic polygon (Ward) needs to be represented for multiple site. Have just one Ward column results in each ward only being displaced for one single site, which would be fine if none of the areas overlap. As it is, that system of only four columns produces problems where areas overlap. Hence my work around of splitting it into a separate column for each site. Dec 1, 2017 at 10:18
  • 1
    You could create duplicate polygons.
    – csk
    Dec 15, 2017 at 19:56

2 Answers 2


If I'm understanding your question correctly, you can handle this with Atlas and Rule-based styling.

It sounds like you want the styling to change based on your atlas feature. To make this work your atlas table will need a column that specifies what column to use for the styling. For example, let's say you have column in your atlas table is called "Column" that then has entries for each of the columns you will use. Using your example, you would have entries that say "Site 1", "Site 2", "Site 3", etc.

Once you have this, go to your layer styling, and change "Graduated" to "Rule-Based" This will create a series of rules representing your graduated styling. In the example above, you'll see something that looks like:

'Site1_1' >= 0 AND 'Site1_1' <= 0.6 'Site1_1' > 0.6 AND 'Site1_1' <= 0.65

This should display exactly like the graduated styling. Now change each entry of 'Site1_1' to: eval(attribute(@atlas_feature, 'Column'))

so your first line looks like: eval(attribute(@atlas_feature, 'Column')) >= 0 AND eval(attribute(@atlas_feature, 'Column')) <= 0.6

Now when you go to your atlas and preview, the symbology will change based on the column specified in the active atlas feature.

Here's an example setup with a point file that has a number of different columns enter image description here

I made a table for the atlas with fields called "Column" and "Page" enter image description here

The atlas setup is as follows enter image description here

and styling is Rule-based using the atlas features enter image description here

When you change the atlas page, the styling will change which column it is based on.


Inspired by the comment of @csk, you can create a new layer with duplicate polygons of every Ward combined with every Site.

This can be done with sql, using union all.

Open DB-manager and go to Virtual Layers > Project layers

Open the SQL-window and write following code, changing 'your_layer' to your layername

select geometry, WD11CD, site_1 as color from your_layer
union all
select geometry, WD11CD, site_2 as color from your_layer
union all
select geometry, WD11CD, site_3 as color from your_layer
union all

Check 'load as new layer', select geometry-column, give your layer a name and click 'load'. A new layer will be added to your project.

You can now choose this layer as the one referenced by the Atlas-generator

--- another aproach ---

if you have too many sites to union, you can try another workaround.

Save your layer as Spatialite.

Connect to your spatialite-file with DB-manager.

Open SQL-window and run following code (you first have to change 'your_layer' with the correct layername. you have to do it twice):

SELECT ' select geometry, WD11CD, '|| name || ' as color from your_layer union all' as sql FROM pragma_table_info('your_layer') where name like '%Site%'

Load this result into your project as a geometryless table.

Save that table as a .csv (tab-delimited)

Open the csv with a texteditor (eg. notepad++).

Remove every double qoute (") and the last 'union all'

Copy erverything and paste it back into the SQL-window.

Now you have the code as above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.