5

At 3.10.3, I can successfully apply an outer glow to a line, as with the orange example here:

enter image description here

I would like to have the glow on just one side of the line but I cannot find a way to do that. Thanks in advance.

EDIT:

Following ahmadhanb's instructions, here are my before and after screenshots, with the basemap removed for clarity:

Before:

enter image description here

After:

enter image description here

The glow is shifted to the lower-right. Unfortunately it does not stay "locked" to just one side of the lines. I also adjusted some of the other Transform properties, but did not find a suitable way to solve my original question.

1
  • Can the data be a polygon with just the outline symbolized?
    – HeikkiVesanto
    Commented Mar 18, 2020 at 15:23

2 Answers 2

4

Here is a bit of a workaround.

  1. Use geometry generator to generate a line that is 'buffered' out from the original one in one direction. I used this expression: difference(boundary(single_sided_buffer($geometry,(0.001*@map_scale))),$geometry)

    (using scaled map units for buffer size - you may need to modify accordingly especially if not using a projected CRS)

    It is the difference between the original line and the boundary of a single-sided buffer to the left. See the dotted line below. (To buffer to the right use -0.001)

enter image description here

  1. Move the original line above the generated line in the list of symbols using the little up arrow button, as below

enter image description here

  1. Style the generated line to have an outer glow but no Source

enter image description here

enter image description here

With the @map_scale expression above it should work even when zoomed out:

enter image description here

Because of the single-sided buffer it will always stick to one side of the line depending on the orientation in which it was drawn. See the lines below - if you draw a 'closed' line going clockwise it will draw the buffer on the outside (left). If the line is anti-clockwise it will be on the inside.

enter image description here

If some of your lines are not drawn in the right order you can reverse them by selecting the lines you need reversing and using the Reverse line direction tool in the Processing toolbox (and click the Edit Features In-Place button at the top so that it will just edit those features without creating a new layer).

2
  • Bravo! Well done! I'm left in awe... If it were possible, I'd buy you a beer for your efforts! +1 also for the creative geometry expression; I'm still studying it, trying to learn from it. A quick note: if the Outer Glow Spread value is set too high, the glow will bleed across the solid line. For my use, I set the @map_scale factor to .002, the Spread to 3.0 and the Blur Radius to 1.0.
    – Stu Smith
    Commented Mar 21, 2020 at 5:02
  • It was an interesting problem to work out, thanks for the kudos! The geometry generator expression is relatively simple, in my case my CRS is metre-based so 0.001*@map_scale should get you the equivalent of 1 millimetre at 1:1, 1 metre at 1:1000, and so on, behaving somewhat like it's in display-based units (points, millimetres in print, pixels) rather than geographic real world units. Buffer by that amount and you get your maximum glow distance from the original line. I didn't check how well this effect shows up in the map layout legend though, generated geometries can look weird
    – she_weeds
    Commented Mar 21, 2020 at 10:59
4

You can use the Transform under the Effect type in which you can shift slightly the Outer glow using Translate x,y as follows:

  1. Activate the Draw effects:

enter image description here

  1. Add a new effect, and under effect type, select Transform. Put the Transform layer between Source and Outer glow. Choose Modifier Only under Draw mode, and select pixels as unit. Then change the x and y under Translate to shift the Outer glow:

enter image description here

  1. Change the Draw mode for both Source and Outer glow layers to Render only

Here is the final output:

enter image description here

1
  • Smart idea (+1), however I think the parameters of the transform can't depend on the geometry of the line, i.e. are just hand-adjusted to work. That can be done for a single simple zig-zag but likely to be kloogey for a more complicated line.
    – Houska
    Commented Mar 18, 2020 at 16:03

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.