In QGIS 2.0 I can use with success the $scale function in the labeling expressions.

When I tried to use it for symbolizing in the data defined properties it has a value of 0.

Is there a way to make it perform like it does in labeling (getting the scale)?

As I saw in the expression string builder help that

$scale function
Returns the current scale of the map canvas. 
Note: This function is only available in some contexts and will be 0 otherwise.

is there a source where I can read more about this e.g. in what contexts it is available? Thanks, Tudor

  • 1
    Have you tried using it because the dialog will show 0 even if it is used when the expression is evaluated. It will show 0 just because the dialog doesn't know about the map canvas so it can't get the scale at that point (to be fixed) – Nathan W Oct 20 '13 at 4:00
  • I have tried using it without success. – tudorbarascu Oct 20 '13 at 16:02
  • Could you share your expression that you used for scaling labels? – mixedbredie Nov 6 '13 at 17:01
  • CASE WHEN $scale > 500 THEN ..END.. – tudorbarascu Nov 6 '13 at 20:47
  • The sintaxis is similar to used in raster calculator. – xunilk Apr 12 '15 at 11:43

The problem was in to use directly with a wrong sintaxis expression.

When I put only $scale in the browser I got:

enter image description here

By using the rule ($scale <= 500)*$scale; where the sintaxis is similar to used in raster calculator. In the image below the rule is not reached ($scale <= 500 = FALSE = 0):

enter image description here

When the rule is reached the scale ($scale <= 500 = TRUE = 1) is displayed if it is used the adequate product; ($scale <= 500)*$scale:

enter image description here

It works.

| improve this answer | |

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.