<div dir="ltr"><div dir="auto"><div>Laurent and list,<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Oct 12, 2025, 10:27 celati Laurent via QGIS-User <<a href="mailto:qgis-user@lists.osgeo.org" target="_blank">qgis-user@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Dear all, <br><br>I'm working with QGIS and, if necessary, PostGIS.<br>I have two vector layers :<br><br> - A first polygonal layer resulting from vectorization work using photointerpretation of the aerial imagery (in blue in the attached screenshot below).<br> - A second polygonal layer in the same area resulting from segmentation of the same aerial imagery (in yellow in the attached screenshot below).<br><br><img src="cid:ii_mgnz6sle0" alt="unnamed.png" width="578" height="278"><br><br><br>Each feature in the two layers has a unique identifier (representing thanks to labels in the screenshot).<br><br>I'd like to be able to produce a small performance indicator of the segmentation performs in faithfully matching the photointerpretation. I was thinking there's probably something that could be done with geoprocessing (union, intersection?) and a area calculation ? An indicator of segmentation performance could be: for each photo-interpreted feature/polygon, calculate the percentage of the surface area covered by the feature in the segmentation layer with the biggest overlap ?<br>To be more specific, in the example screenshot, this could be:<br>"For feature 11 in photo-interpretation layer (blue), I would like to know the percentage of the surface area covered by the feature in the segmentation layer that has the highest overlap with this feature 11 (in this specific case, it's probably feature 42 in yellow)."<br><br>This could be: area of feature 42 overlapping feature 11 / total area of feature 11?<br><br>I don't know if I'm on the right path. How could we translate/reach this needs toward a QGIS and/or PostGIS tool?<br></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">One way to do this is an intersection of the two polygon layers, using ST_intersection. This will create a bunch of "sliver" polygons with the ID pair (for example) and the area of the sliver. You will want to sum the area grouping by the two layer ids as in general the boundary on one layer may be split into several pieces by the boundary on the other layer.</div><div dir="auto"><br></div><div dir="auto">You can put that in a temporary table called slivers. You don't need the geometry, just the polygon ids from each layer and the area of intersection. Your table might look something like this:</div><div dir="auto"><br></div><div dir="auto"><span style="font-family:monospace"> interp_id | segment_id | area <br>-----------+------------+------<br> 1 | 1 | 15<br> 1 | 2 | 0.2<br> 1 | 3 | 0.1<br> 1 | 4 | 0.2<br> 2 | 1 | 0.2<br> 2 | 2 | 12<br> 2 | 3 | 0.1<br> 2 | 4 | 0.1</span><br><br></div><div>Then you can do something like this:</div><div><br></div><div><span style="font-family:monospace">select slivers.interp_id,sum(slivers.area) differentials<br>from slivers<br>where slivers.area != (select max(others.area) from slivers as others where others.interp_id = slivers.interp_id group by slivers.interp_id) <br>group by slivers.interp_id;<br><br>select slivers.interp_id,sum(slivers.area) congruencies<br>from slivers<br>where slivers.area = (select max(others.area) from slivers as others where others.interp_id = slivers.interp_id group by slivers.interp_id)<br>group by slivers.interp_id;</span></div><div><br></div><div>which would produce something like this:</div><div><br></div><div><span style="font-family:monospace"> interp_id | differentials <br>-----------+---------------<br> 1 | 0.5<br> 2 | 0.4<br>(2 rows)<br><br> interp_id | congruencies <br>-----------+--------------<br> 1 | 15<br> 2 | 12<br>(2 rows)</span><br><br></div><div>Of course, the above two select statements will produce an error in the (edge) case where the sum of the bits of non-overlap are exactly equal to the overlap in area.</div><br></div><div>You can further join the sum of all areas in each interpreted polygon to the two selects above if you want to calculate a percent of differentials and congruencies.</div>
</div>