Thursday 18 July 2019

qgis - Is there any way of making label size dependant from the value of an attribute?


I know QGIS has a feature to make labels size dependant from an attribute:


Option


The problem is that I don't know how to choose a maximum size or even a size variation-scale. It makes the size proportional to the values of the chosen attribute, which sometimes makes the lables too big (or too little):


Problem



I've tried to use the "expression" labeling (for example using logarithms), but I don't know how to make the maximum and minimum be less "extreme".


Is there a way (maybe through an expression) to make the size of the labels more visual-friendly? Something to make those labels "less proportional" to the attribute.



Answer



I think i've found a solution trying random functions and expressions. There is a function called "scale_linear" that allows to make a linear dependency.


I put the field name in the "input domain" and define a domain-range between the minimum and maximum value of my attribute (in my case 0.1% and 15.1%) then I put the output range (label size) I want as a minimum and maximum (in my example 5mm and 8mm).


enter image description here


So this is what happens:


The function assigns a size of x[5; 8] to an attribute y[0; 15], in a linear way. So:


0 % = 5 mm


15 % = 8 mm



And the result is:


enter image description here


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...