2

In QGIS 3.16 I have prepared an atlas of a city, based on a UTM 500x500 m grid. When displaying each cell in the atlas, I want its label to have a larger font size than its neighbours:

enter image description here

In the string builder for the font size

enter image description here

I've built the following code, but it doesn't work

if(within($geometry, @atlas_geometry), 12, 7)

What's wrong?

6
  • 1
    Try removing the "=1", so your expression would become if(intersects($geometry, @atlas_geometry), 12, 7) Dec 10, 2021 at 16:42
  • I did test on 3.16 and it seem that the "@atlas_geometry" return "<empty geometry>" when used in the label context (in symbology context I did get the expected "<geometry: MultiPolygon>")
    – J.R
    Dec 10, 2021 at 16:59
  • Can you please show an example? I do not really understand what you are trying exactly to implement :D
    – Taras
    Dec 10, 2021 at 17:27
  • Maybe a bit more context would help understanding the intention - I can't really imagine what/where exactly you want to apply this. You have an atlas with coverage layer (e.g. admin. units) and objects inside the current admin. unit should be larger than outside? Is this correct?
    – Babel
    Dec 10, 2021 at 17:28
  • Question edited. I hope it's clearer now :)
    – jpinilla
    Dec 10, 2021 at 18:01

1 Answer 1

4

Use rule based labeling and set two rules:

  • within ($geometry, @atlas_geometry ) for the features inside the atlas geometry
  • not within ($geometry, @atlas_geometry ) for all others

See the settings on the right. Highlighted in red the current atlas feature: enter image description here

2
  • did you know why these exact same expression didn't work when used as data defined override for label text size ? Your solution as the advantage of being more discoverable and probably should be preferred anyway but I'm curious
    – J.R
    Dec 11, 2021 at 0:38
  • No, I don't konw why that is. Maybe worth another question here, just for curiosity
    – Babel
    Dec 11, 2021 at 9:09

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.