I would like to decrease the opacity of my layer when zooming out.

I prepared something like this:

 When @map_scale>1750 Then (1 - transparency) * 255

It doesn't work.

The similar thread is here:

How to set transparency per polygon in a shapefile in QGIS?

but applies to the shapes

How to make the scale-dependant label transparency?

  • Are we talking about total label transparency, or only the background?
    – Erik
    Commented Oct 14, 2020 at 8:29
  • Where do you use this condition?
    – Taras
    Commented Oct 14, 2020 at 8:34
  • 1
    Also, what is "transparency"? An attribute column? If so, what are its contents? Furthermore, why are you multiplying by 255?
    – Erik
    Commented Oct 14, 2020 at 8:36
  • I mean label opacity
    – Geographos
    Commented Oct 14, 2020 at 8:43
  • 1
    First tab of Edit (lable) rule has an Opacity slider
    – Bera
    Commented Oct 14, 2020 at 8:52

2 Answers 2


The expression for label opacity based on scale:

if(@map_scale>1750, 50, 100)

The expression for polygon fill opacity based on scale:

color_rgba(255, 0, 0, ( 1 - if(@map_scale>1750, 0.5, 0)) * 255)

Now both the labels and polygon fills are 50% transparent if you zoom out of the 1:1750 scale. The different syntax is caused by the fact that label opacity is a value in range [0, 100], while polygon fill is constructed as an RGB alpha color.


Apply the following query for the opacity of labels in the Expression String Builder (Expected Format: int[0-100])

WHEN @map_scale> 750 THEN 20

Map Scale: 1:578

enter image description here

Map Scale: 1:1157

enter image description here

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.