# Adding lines to polygons in QGIS

I'm mapping quick clay risk areas and have extracted areas which could trigger slides (slope > 1:2.5; height (min/max) > 5m). The areas are separated into zones of roughly equal aspect (30 deg), giving me a direction for each area.

Now I want to map the respective release areas, which are defined as 20x the length of the trigger area.

I thought of resolving this by adding a line (or many) to each area, in the direction of the (rounded) aspect -> cutting the line at the border -> adding a new line 20x the lenght of the line inside starting at the end point.

My problem is, how (if possible at all) do I add lines with a direction to a polygon? Simply min/maxing (using the min and max elevation point inside each polygon) didn't work out, as it often gives a different direction than the aspect due to the nature of, well, nature.

Data available is the DTM, and based on that my trigger areas, aspect etc.

Screenshot plus drawing for explanation:

screenshot: drawing:

• Not sure what is your question, do you want to add lines in the polygon dataset or rather want to derive a deriction automatically from the average slope orientation of each polygon? Commented Apr 26, 2022 at 10:32
• @Al-rl I want to add lines inside each polygon (geographically) in the direction of the given (rounded) aspect Commented Apr 26, 2022 at 10:35
• Do you have attributes with the line lengths and azimuth?
– Bera
Commented Apr 26, 2022 at 13:27
• So using zonal stats to get the mean and then using that as the line orientation should be fine. If you want a line reprensation go for the fill, otherwise you can use the generate geometry grom expression to create the line from the extent. I assume that would get you there. Commented Apr 26, 2022 at 20:20

Okay, so I believe I found the solution - thanks guys for the tip of using "geometry from expression", that was the ticket!

Should anyone else get this problem:

Firstly, I converted my aspect zones (polygons to lines, then lines to points), giving me more than enough points along the borders (since they were originally taken from a raster file, it's rather square-y).

Then, I modified the formula given in the answer here: QGIS: writting an expression in geometry generator for a straight line with given azimuth using my aspect and the points at the border, the expression looking something like this:

``````make_line(start_point(\$geometry),project(start_point(\$geometry),1000,((pi()/180)*aspect))
``````

This gave me 1 km long (as in: more than enough length) lines in the direction of the aspect.

The next part will be to cut the lines to fit into each polygon (since the individual FID didn't get lost during conversion, it should be rather easy), extracting the length of each line, multiplying by my factor (20), and elongating each line by that amount, from the end point. I then can connect the new end points of each line, making new polygons from them, joining by FID and will end up with my release areas

• I don't know if it can be useful but I created an alg for QGIS to create a line patern fill with an angle and a distance between lines. I imagine a processing like "Geometry by expression" to generate the lines. Link : gis.stackexchange.com/a/354581/93097 Commented Apr 27, 2022 at 10:16