You can use QGIS Expressions either with Geometry Generator or Geometry by expression (see here for details) to automatically create the lines you look for. Use this expression (step-by-step explanation how it works below):
intersection (
collect_geometries (
array_foreach(
generate_series (
0,
x_max($geometry)-x_min($geometry),
10
),
offset_curve (
make_line (
make_point (
x_min($geometry),
y_min($geometry)
),
project (
make_point (
x_min($geometry),
y_min($geometry)
),
y_max($geometry)-y_min($geometry),
0
)
),
-@element
)
)
),
$geometry
)
Screenshot: the expression applied on the polygon layer with Geometry generator. Use Geometry by expression instead to create a new layer with actual geometries:

How this solution works:
How this solution works (see next screenshot below):
Create a point (blue dot on the screenshot) at the bottom left of the extent of the polygon layer: make_point (x_min($geometry), y_min($geometry))
Calculate the length of the north-south extent (=the theoretical maximum length a line can have): y_max($geometry)-y_min($geometry)
Create a point (red dot) to the north of the blue dot from step 1, in the distance calculated in step 2. use the function project(point,distance,azimuth)
and fill in the expression from step 1 for point
and from step 2 for distance
- abbreviated in what follows as [1]
and [2]
. The azimuth should be 0
to get lines in N/S direction. The expression looks like this:
project ( [1], [2],0)
Create a line connecting the point from step 1 to the point from step 3 (blue line on the screenshot). Again, replace [1]
and [3]
with the expressions from the respective step: make_line ( [1], [3])
Shift this line for 10 meters to the right to get the orange line: offset_curve ( [4], -10)
To repeat the shift, add an array_foreach()
function. There are several sub-steps necessary:
You want to have a line all 10 meters. So start with 0 (the blue line), 10 meters (orange line), 20 meters and so on until you reacht the right corner of the polygon. Thus create an array like [0, 10, 20, 30, 40, 50 .... n], where n is the last line. To calculate n, get the maximum extent of x-coordiante values (the right-most point in your polygon) and substract from it the minimum extent of x-value (the left-most point of the polygon): x_max($geometry)-x_min($geometry)
. Now you can create the array with generate_series(start,stop,step=10)
: generate_series (0, x_max($geometry)-x_min($geometry), 10)
Now you can use the array created to shift the line for each value in the array: 0 meters, 10 meters, 20 meters, 30 meters .... n meters: array_foreach( [G], [5])
- [G]
is to be replaced by the generate_series ()
expression from above and in the epxression from step 5 ([5]
), replace -10
with -@element
- you don't want to shift for 10 meters, but for each of the values we created in the array in the generate_series()
part of the expression
- The output of step 6 is an array of geometries (lines). To convert this to geometries, add
collect_geometries ([6])
. This is the output you get:

- As you only want the lines inside the polygon, add an intersection-funtion:
intersection ([7], $geometry)
And here you are with the lines you wanted:
