5

I'm trying to create a multiline geometry looking like the lines in my screenshot. I've created it by duplicating a line style 12 times on a point layer, rotating it by +30 degrees.

Isn't it possible using one expression? Like this (ERROR):

--first line
rotate(
    make_line(
        centroid($geometry), make_point(x(centroid($geometry)), 
        y(centroid($geometry))+1000))
, 0, centroid($geometry))
,
--second line
rotate(
    make_line(
        centroid($geometry), make_point(x(centroid($geometry)), 
        y(centroid($geometry))+1000))
, 30, centroid($geometry)),
,
--third line
rotate(
    make_line(
        centroid($geometry), make_point(x(centroid($geometry)), 
        y(centroid($geometry))+1000))
, 60, centroid($geometry))
...

enter image description here

1 Answer 1

6

You can use generate_series() together with array_foreach() for this purpose and then use collect_geometries() to turn the array of lines into a multiline geometry:

collect_geometries(array_foreach(generate_series(0,330,30), -- 330 instead of 360 to not draw the line at 0 and 360 twice
rotate(make_line(
centroid($geometry), make_point(x(centroid($geometry)), 
y(centroid($geometry))+1000))
,@element,centroid($geometry))))
0

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.