2

I want to iterate several maps using the atlas feature of the print composer in QGIS 3.4. The field I want the maps to iterate over has several duplicate values (ie several features belong to the same group and are labelled as such) but at the moment, atlas produces one map for each feature regardless of the fact that some have the same value in the field they're being iterated over.

What I want it to do is produce a map which is zoomed to fit all the features labelled 'A' and another map zoomed to fit all the features labelled 'B', not one map for each feature.

I could merge the features by their labels, but then I'd lose the remaining attributes which do vary and I'd like to present them in a linked attribute table, so they need to be preserved within the layer really.

All I really want QGIS to do is assign the same @atlas_featureid to all the features labelled 'A' and a different @atlas_featureid to all the feature labelled 'B', my existing set-up will do the rest.

0

Use the Dissolve tool to create a new layer where features with the same value are merged into one feature. Use the dissolved layer to control the Atlas, but don't display it on the map. Display the original layer on the map.

  • This is a good start and set me on the right track, so thanks. The trouble is that the dissolved layer then contains all the feature IDs and they don't necessarily link to the attribute tables from the undissolved layer. The nub of the problem really is getting the atlas to see that all features labelled 'A' on a table relate to the features shown on a map. Dissolve gets atlas to see all the features as one, but does not link the table to them. – user39790 Nov 27 '18 at 18:18
  • The workaround I used in the end is to follow your suggestion, but also concatenate the tables (using sql), then present the data with the attribute table wrapped on comma. It sort of makes a table of all the features, but with no horizontal lines. Not sure it's any easier than just filtering all the tables manually though. – user39790 Nov 27 '18 at 18:19
  • I was assuming that 'A' and 'B' were values in a "group_ID" field in the attribute table. You should be able to filter the attribute table item (in the print composer) to just features with the "group_ID" of the Atlas feature. If this doesn't address your issue, I must have misunderstood how your data and/or tables are structured. Please edit your question and add more information. – csk Nov 27 '18 at 18:33
  • I'm not sure I understand. On an atlas page, I have a single map (showing my now grouped features, or at least with the zoom controlled by them). I also have a single table from the ungrouped layer. I can filter that table by atlasfeature_id, but that won't work since the atlasfeature_id is an internally assigned value, not my actual labels 'A' and 'B'. I could filter the table manually by a label, but then that same filter would apply to all atlas pages, if I filter by 'A', it wouldn't change to 'B' when the 'B' features are zoomed to. Am I missing something? – user39790 Nov 28 '18 at 8:34
  • 1
    Set the atlas page name to the field that 'A' and 'B' are in.Then use the atlas_pagename variable to filter the tables. – csk Nov 29 '18 at 17:31
0

You can create a virtual layer and select distinct values. Then use this to control the atlas . Look at Getting list of distinct values from shapefile field using QGIS?

  • This answer's length triggered an automatic review for low quality. We're looking for detailed answers, spanning multiple paragraphs and referencing documentation and/or screenshots. Please Edit this answer. – Vince Nov 27 '18 at 3:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy