QGIS – How to Color Path/Line with Gradient Colour from Points

colorpathpointqgisstyle

I'm using QGIS 3.16.15-Hannover (LTR).

By using "Points to path" from the toolbox I created a path/line between several points from a CSV. However, I did not find any way to colour the generated path by attributes. I would like to have a colour gradient from the first to last entry.

To explain with a gradient from white to black: The line from point 1880 to point 1890 should be white, the line from point 1890 to point 1900 should be light gray, …, the line from point 1930 to point 1940 should be black.

How is this possible?

I assume I need another tool instead of Points-to-path.

My CSV looks like this:

year;x;y
"1880";26.31547;59.71049
"1890";26.21103;59.63769
"1900";26.23298;59.59843
"1910";26.48264;59.62822
"1920";30.01107;60.03541
"1930";30.13071;59.99484
"1940";27.81746;59.24653

Palette:

year;colour
1880;#0037ff
1890;#8f77ff
1900;#cdbaff
1910;#ffffff
1920;#ffbfaa
1930;#ff7b5a
1940;#ff0000

Best Answer

You can set the style of the line to Symbol layer type of Interpolated Line and apply a color ramp. Then the line from the start to the end is styled in a smoothly changing color ramp:

enter image description here

Related Question