2

I'll try and lay this out clearly, I have most of it covered, but there's a very specific thing I'm looking for in the rules - whether or not it can be done and if so, how?

Key things I have done and/or plan as outcomes;

  • QGIS 3.4.2
  • A dataset of just over 556000 rows - all points representing one building each
  • 583 groupings for each by round which are unique, the name covers region, service, round number and day like so '(SH) Food 1 Mon'
  • These rounds have anywhere between a few hundred and several thousand points in each
  • The groupings have been first set as categorised and then Rule-Based so each round is split out from the others
  • They're to be exported via an atlas and show one round at a time (once I've bounding geometry to use for each round) and all will have the same symbols - with only one round showing each time, there's no demand to have different symbols

I'm looking to use an atlas due to the volume of images this will produce, doing it by hand would take an age.

Previously when doing similar work on far less categories I've used this code and adapted it for each category (this is using the round example from above)

if("Round Name" = @atlas_pagename, "Round Name" = '(SH) Food 1 Mon', Null)

That works perfectly once all categories have the right round name in before the Null and also the ELSE category has been deleted.

Now here's where I've become stuck - with 583, it takes an awfully long time to change each category by hand once I've moved from Categorised to Rule-Based.

So, the key question here is this; there a way of putting a variable in where I've been typing the round name in order to have QGIS do that part for me by reading and using each round name for each category?

I've looked around on here and not found anything apart from using some Python script which I'm not very handy with so thought I'd ask this first before trying to get my head around that.

I think that covers it and hopefully it's all clear!

8
  • I'm not sure exactly what you're trying to accomplish. Is it only about showing certain points on every atlas page? How are the atlas pages defined? Can a direct match be made from a field value to the atlas page?
    – Gabriel
    Commented Jan 8, 2019 at 16:42
  • That's a possibility actually, not built the bounding layer yet so could try that. Essentially I'm trying to have the text of the round name filled out by QGIS and not me, so it needs to read it from the Round Name field and print it there in the expression. Without that, I end up doing them by hand so lots of clicking, copy, paste etc etc to make all the rules unique
    – Fordonian
    Commented Jan 8, 2019 at 16:49
  • If that's the case, you only need one rule where that field needs to match the atlas page and that's it. Features will only show when the correct atlas page is active.
    – Gabriel
    Commented Jan 8, 2019 at 16:53
  • Also if you need to get the round name field value of each feature in an expression, take a look at this function attribute( $currentfeature , "your_field") under the Record and Attributes section. If this covers what you need then the suggestions in the comments can be put into a useful answer form.
    – Gabriel
    Commented Jan 8, 2019 at 17:03
  • 1
    Finally had the time to look at this and yes attribute worked! I think I'd started from a position of over complicating things and looking to have a rule per category, not realising I could just have the one which would work. All running well and part way through running out 583 images at time of typing. Thanks for the help!
    – Fordonian
    Commented Feb 4, 2019 at 13:01

1 Answer 1

4

Since your goal is to display, on each atlas page, a different value for a single field in your data, it shouldn't require multiple rules.

You can read the value for each feature at render time using the Expression Builder. While the function attribute( $currentfeature, "your_field") can help return field values dynamically for each feature, in your case, this isn't necessarily needed. If there are corresponding fields in your coverage layer (where the corresponding field controls atlas page name) and data layer (where the corresponding field contains the round number), it can be as simple as this symbology rule for your data layer:

"Data_layer_field" = @atlas_pagename

This will show only features for which the fields match.

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.