The Virtual Layer way
Assuming that you have a Ploygon vector layer named plots.
Assuming that each feature of the plots layer has plotId and area fields.
You can create a Virtual Layer with one feature for each pair of geometries in the layer plots that are touched, with the following SQL query:
ST_Union( p1.geometry, p2.geometry) geometry,
( p1.area + p2.area) sum_area
ST_Touches( p1.geometry, p2.geometry)
p1.plotId < p2.plotId
The Output is a new Multipolygon virtual vector layer with one (see DISCLAIMER and EDIT) feature for each pair of plot geometries that touche, plotId1 and plotId2 fields, and sum_area field with the sum of the areas to search.
Note that when digitizing the test plots I had to enable the topological edition for the perimeter segments to be recognized by the
ST_Touches() function, if your plots do not meet topological conditions you can try adding an
OR ST_Overlaps() similar condition in the
I am giving my first steps with SQL queries in PostGIS, therefore all kinds of suggestions and observations are accepted and welcome. I don't know how to select a single feature for each pair of plots. For example, if the geometries of plotId 5 and plotId 6 are touching each other, there will be a feature in which
plotId1 = 5 and
plotId2 = 6, but there will also be another feature in which
plotId1 = 6 and
plotId2 = 5. Both features with the same sum of area and spatial equivalent geometries.
Thank you Cyril very much for this comment to avoid mirroring.