I don't know of a way to access the "base" symbol size, as you would the "base" symbol color using @symbol_color
. You can, however, effectively duplicate it using layer-level variables.
For instance, I have a placemark layer with different symbols (sometimes compound symbols) based on placemark type. In Layer properties / Variables for the layer, I define a variable @symbol_size
set to '2.4'
(base symbol size in mm).
Then I have a categorized renderer which renders structures as filled grey boxes whose size is a data-driven override, @symbol_size * 0.75
. A historical site is an X with size @symbol_size * 0.60
. And a marked destination is an O with size @symbol_size
(implied * 1.0).
You could do the same in your instance with a graduated renderer accessing the (manually defined) @symbol_size
variable in an expression reflecting the scaling attribute desired.
If you save/reuse styles, you should think what will happen (and what should happen) if you or another user load this symbology style but don't define the @symbol_size
variable in the layer properties. In this case, QGIS will (depending on expression) most likely evaluate all the data-driven overrides as NULL, and so will not override whatever was entered as the base size for a line or symbol. It would be easy to forget that unlike @symbol_color
, your faked @symbol_size
is not autopopulated.
To scale all your symbology up or down, you just now have to edit the variable value in layer properties; you should no longer change it using the layer properties size value directly.
Finally, it is worth noting the variable you create is stored and populated as a string, but QGIS seems to be smart enough to convert it silently to a number if used in a simple arithmetic expression. But in a more complex expression you may need to type-convert it.
scale_exp()
andscale_linear()
if one knows the correct settings. E.g.scale_linear("the_val",minimum("the_val"),maximum("the_val"),0.2,3.0)
should or could do it, where0.2
and3.0
are the Size from and Size to values. If you can verfiy this, it is an acceptable answer ;) Meanwhile I figured out that my actual issue (not the question) is already solved by QGIS: I can just enter a fixed offset half the size of the "fixed" stroke width (even though it is not fixed), and no overlap will happen. Cant really explain in words and logic why this already solves the issue.