# Create parrallel lines in symbology according to attributes

I have a vector layer as lineString geometry type.

This layer has 2 attributes:

• true_side is the line spacing.
• true_witdh is the total width to distribute lines

The number of parrallel lines is equal to true_witdh / true_side

The goal is to find a way in symbology in QGIS to render parrallel lines to the initial geometry with a non constant number of lines.

As show on the figure bellow:

true_side = 1

true_width = 4

There are 5 lines in total: 4 on sides + the middle one

I have tried a lot of combinaisons on qgis without succes I can only achive to get this:

Use Geoemtry Generator with the expression below (explanation at the end of the solution).

Initial lines (red) with a different number and spacing of lines (black), denpending on the attribute values (see labels):

``````collect_geometries(
array_foreach(
array_remove_all(
generate_series (-true_width/2, true_width/2, true_side),
0
),
offset_curve (\$geometry, @element)
)
)
``````

Explanation:

Use `offset_curve()` to create the lines. To create several lines, iterate (create several lines at different distances) over the `offset_curve()` to create different distances for the shifted line. Use `array_foreach()`, based on an array that represents these different distances. Lines should be created to the left of the initial line (positive values) and on the right (negative values).

The different distances correspond to an array starting from a negative value of `half of true_width` to the positive value of `half of true_width`: so together, it results in the `true_width`. If `true_width` e.g. is 24, the array starts at -12 (distance of 12 right of initial line) and goes to +12 (left of line). The interval corresponds to `true_side`. If this is 4, the array looks like: `(-12, 8, 4, 0, 4, 8, 12)`. Optionally, you can remove 0 with `array_remove_all()` as this would only recreate the initial line.

This returns an array of lines that you can collect to a geometry collection using `collect_geometries()`.

• Thank you A LOT! I have searched for more than 8 hours... Commented Jan 9 at 23:01
• The benefit of asking a good question on GIS SE. Rather invest half an hour in a good question than 8 hours in frustrating searches... Commented Jan 9 at 23:24
• I have done both so far ! Plugin finished github.com/vincentBenet/QGIS-plugin_qgis-to-ugcs/releases/tag/… Commented Jan 10 at 13:25
• OK, what does the plugin do? Commented Jan 10 at 14:05
• Export drone path of scan Area from line for a drone software called UGCS Commented Jan 10 at 14:33