Label size relative to atlas in QGIS

atlasfontlabelingqgis

In QGIS 3.16 I have prepared an atlas of a city, based on a UTM 500×500 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?

Best Answer

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

Related Question