You can create parallel lines with Geometry generator (or geometry by expression, see here for the difference) and intersect them with the polygon. Than style this lines with
Marker Line symbology. This is for visualization purposes; if you need actual geometries, it works very similarly, but with a few differences, see below.
For visualization purposes
To get horizontal lines, simple create the bounding box of the polygon and create a line from the upper left to the upper right angle of this bounding box, than shift this line in parallel several times for a defined interval -
70 [meters] in my case: you can change this value on line 8:
Screenshot 1: the undelying dotted lines are here for visualization purposes only (I added an additional symbol layer):
Screenshot 2: Setting
Marker Line with interval (one point every 100 m) and offset (first point 20 m from the polygon boundary on the left side):
To create actual geometries
If you have several polygons where the lines created in step 1 intersect with more than one polygon, see below how to solve this (it's based on this here, but with some other workflow except step 1 and 4 from here).
In principle, to create actual geometries, it works very similar as the solution above for visual purposes only:
Menu Processing / Toolbox / [Geometry by expression] with the same expression as above, but only starting from line 3 (
collect_geometries ( and deleting the closing bracket
) on the last line. This creats lines that project beyond the polygon.
Use Menu Vector / Geoprocessing tools / Clip
, set the line from step 1 as input and the polygon as Overlay layer`. You get lines clipped to the polygon.
All lines are part of one multipart geometry, but we want a single feature per line, thus use
Menu Vector / Geometry Tools / Multipart to singleparts.
Menu Processing / Toolbox / Points along geometry, where you can define the
Start offset for the points to be generated.
To avoid overlapping of the lines with neighboring polygons
Preparation: be sure you polygon layer contains an attribute with a field containing a unique identifier (field
id in my case).
Step 1 as above (Geometry by expression), result:
Menu Vector / Geoprocessing Tools / Clip, set the lines created in step 1 as
Input layer and the polygon layer as
Overlay layer, result:
On the lines created in step 2, run
Menu Vector / Geometry Tools / Multipart to singleparts - output visually looks the same as above.
Nex click the icon
Select by expression, paste the following expression an apply it to select all lines (highlighted in yellow in the next screenshot) that can be deleted. Replace
'polygon' with the name of your polygon layer and
id with the name of your attribute field containing the unique identifier:
Toggle editing and delete the selected lines.
Continue with step 4 from the previous solution above:
Points along geometry - see result:
Old solution, still preserved in case it's useful for others
This is an option to create not horizontal lines, but lines parallel to one of the polygon boundary segments.
As you don't provide more details, I show how I did it: adapt this to your use case (details below). Create a new symbol layer on the polygon layer, set it to
Geometry Generator / LineString and paste this expression. Style the lines thus created as
generate_series (1, 5000, 70),
Screenshot: the undelying dotted lines are here for visualization purposes only (I added an additional symbol layer):
How you can adapt this to your use case:
The direction of the line. I took a line parallel to the upper polygon boundary. The upper right vertex of the polygon has index-no. 1, the upper left one is no. 2. So on line 9 and 10, change the index-no of the vertices that form the line to which your lines should be parallel.
The interval between and number of parallel lines are defined in line 5 inside
generate_series(). In my case, it generates parallel lines with interval of
70 [meters], starting from
5000. Increase this last value to get more lines, increase
70 to get more distance between the lines.
The lines normally must be extended to cover the whole polygon. This is done with the values in line 12 and 13,
0 in my case. You can safely increase these values as much as you want as the lines anyhow will be "cut" to the polygon extent by the
intersection() function (line 1).
In line 16, you have the variable
@element, refering to the current iteration of the array created in line 5 (the
generate_series() part). Depending to which side of the line you want to create parallel copies, this value must be positive (shifting to the left of the line, than delete the minus sign:
-) or negative (as in my example, than the line is shifted to the right).