Using QGIS 3.22.1. I have straight lines connecting two points. These lines are stored in two separate layers, one layer for each direction.
I am using a graduated size renderer to display these lines. Now they do of course overlap. To prevent that from happening I want to set an offset having the size of the line's width. I know there is a variable to get the current features color (@symbol_color
). Is there a similar variable (or some way) to get the current features width? I want to use it in data defined offset:
Best Answer
When you set the line size with data driven override, you can use the same expression, divided by 2 (offset just half of the line width to keep in touch with the other line) for the offset.
You can use e.g. the assistant to automatically generate stroke width with scale method linear or exponential. When set, you can look up and copy the expression generated based on these settings (see below) under the icon
Data defined override > Edit...
. Copy the expression and paste it underOffset > Data defined override
- don't forget to divide it by 2:When using the assistant for data defined override for stroke width with input source the attribute named
width
with min/max values from0.1
to0.7
that should be styled with stroke width from1
to10
withexponential
scale methdod and exponent0.57
, the expression generated looks like this: