7

Is it possible in QGIS to apply a gradient to linear features? I'd like for some roads to fade from opaque to transparent as they get further away from some set of points. I can measure the distance to any node on the line and thus for each line could define a start and end distance to base the gradient on.

I've approximated the effect I want by splitting my roads into shorter two-node segments and applying color based on the distance to the second node. The effect however is quite discontinuous and there are many more points where semi-transparent lines overlap slightly than there would be if I was using the original linestrings.

Highways fading with distance from street network

Is there any way to make this look a bit better?

(Related questions which I hope are outdated now: Gradient colour for lines, How to visualize measure values along linestrings in QGIS?)

1
  • If you choose a flat cap style instead of square (square is the default), the line segments won't overlap as much. – csk Oct 7 '19 at 21:21
2

Using Geometry Generator in style, you can change line feature to be rendered as polygon. For example added as small buffer, and later on style that buffer as polygon, so add gradient to it.

gradientline

1
  • 3
    That appears to apply the gradient from the top of the screen to the bottom. If I understand the question correctly, the desired effect is for the line to transition from the first vertex to the last, regardless of the direction of the line. – Justin Johnson Oct 8 '19 at 21:52

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.