I'm trying to use the QGIS Atlas tools to build student 'scattermaps', ie. display the school and the students that attend that school, for 215 schools.

The schools layer is the coverage layer, and is being driven by the SCHNUM (school number) value. This is working fine, that is it is driving the pages correctly.

How, though, can I display only features from other layers, in this case the student point layer, that match the corresponding SCHNUM value for the current feature in the coverage layer?

I would also like to switch the coverage layer (schools) to 'hidden' and use the same technique to only display the current school from a duplicate schools layer.

There is a presentation available here that alludes to the use of a layer rendering rule setting using $atlasfeatureid, but I can't figure out how that works.

I also found this bug tracker page that shows this working, but again, I can't get it to work on my data:

  • Sorry to post this as an answer even though its a question. Is there any recommended video tutorial for this? I tried following along and somehow always managed to get lost at some point. Having the same problem. – JRamos Jun 11 '19 at 13:54

Indeed, you need to use rule-based symbology to achieve what you want.

You need to create a rule for what you want to show, and ELSE rule for all others.

enter image description here

In the ELSE rule, deselect the symbol checkbox to make it invisible.

enter image description here

Hide other features from the coverage layer

The rule to show only the current atlas feature can be the following:

$id  =  @atlas_featureid 

enter image description here

note: I believe that @atlas_featureid variable is a 2.12 syntax. I think that in 2.8.x you would need to use a function called $atlas_featureid.

Hide features outside the current atlas feature

The recipe is the same as before, one else rule to hide features, one to show.

For your particular question, you seem to have a shared attribute called SCHNUM. In that case the rule can be:

"Layers_field" = attribute (@atlas_feature, 'coverage_layer_field_name')

in your particular case:

"SCHNUM"  =  attribute( @atlas_feature , 'SCHNUM')

Notice the difference between both SCHNUM. The first, in double quotes, represents each current layer feature's value of the field that stores the school code. The second, in single quotes, is a string with the name of the coverage layer that stores the school code.

Note: Again I think @atlas_feature variable is a "new" thing, and in 2.8.x you will need to use the function $atlas_feature

enter image description here

| improve this answer | |
  • Alexandre very efficient his solution as opposed to computing the intersection. However, what I want to show is a classified layer (thematic map). How would it be to apply your solution in this case? – viniciovcl Jun 27 at 18:29
  • That's another question. The answer involves a few steps. Ask it and ping me, I will try to provide an answer. – Alexandre Neto Jun 27 at 20:57

Your Answer

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

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