Use the following expression (see below) with [Geometry by expression][1], making the following adaptations:
- replace the `@id` of the points at the bottom/top - right/left (use a label with `@id` to see which point has which id); *See [QGIS documentation][2]: `@id` is the newer syntax to use for the older `$id`, so in older QGIS versions, you might have to replace `@id` with `$id`*
- in line 2 (`$id=1`), change `1` to any number of the `$id` of one of the points
- in line 3, change the number to define the numbor of polygons you want to create and replace
- replace `points` with the name of your points layer
*Run [Multipart to singleparts][3] on the resulting layer to get separate features.*
*Works even for irregularily shaped polygons:*
[![enter image description here][4]][4]
This is the expression to use:
```
case
when @id=1 -- must be a valid @id value of one of the points
then with_variable('no',13, -- no. of sub-polygons you want the polygon to divide into
with_variable(
'line1',
make_line (
geometry (get_feature_by_id ('points', 0)), -- @id of point at bottom left
geometry (get_feature_by_id ('points', 1)) -- @id of point at bottom right
),
with_variable(
'line2',
make_line (
geometry (get_feature_by_id ('points', 3)), -- @id of point at top left
geometry (get_feature_by_id ('points', 2)) -- @id of point at top right
),
collect_geometries (
array_foreach (
generate_series (1,@no),
make_polygon(
make_line(
end_point(
line_substring (
@line1,
0,
length(@line1)/@no*(@element-1)
)
),
end_point(
line_substring (
@line1,
0,
length(@line1)/@no*@element
)
),
end_point(
line_substring (
@line2,
0,
length(@line2)/@no*@element
)
),
end_point(
line_substring (
@line2,
0,
length(@line2)/@no*(@element-1)
)
)
)))))))
end
```
*The expression in use, here with Geometry Generator (just for visual purpose, not creating actual geometries):*
[![enter image description here][5]][5]
[1]: https://docs.qgis.org/latest/en/docs/user_manual/processing_algs/qgis/vectorgeometry.html#qgisgeometrybyexpression
[2]: https://docs.qgis.org/latest/en/docs/user_manual/expressions/functions_list.html#expression-function-record-and-attributes-id
[3]: https://docs.qgis.org/latest/en/docs/user_manual/processing_algs/qgis/vectorgeometry.html#qgismultiparttosingleparts
[4]: https://i.sstatic.net/aOSCl.png
[5]: https://i.sstatic.net/loZD5.png