3

I have two vector layers and one of them has different categories (all non-grey colours):

enter image description here

I would like to calculate the percentage of overlap between each level and the other vector layer (colour grey). I know that it can be possible by using the Overlap analysis in the processing toolbox but this only gives the percentage of overlap among the two vectors.

The expected output in the Attribute table should look like this:

Vector A Level 1  10 %
Vector A Level 2  5 %    
Vector A Level 3  10 %
Vector A Level 4  10 %
Vector A Non-overlap  65 %
0

1 Answer 1

2

You can use a virtual layer. My category column is called kkod:

select  g.id, l.kkod, 
        sum(st_area(st_intersection(g.geometry, l.geometry))) / st_area(g.geometry)*100 as overlap_percentage
from grey g
left join levels l
on st_intersects(g.geometry, l.geometry)
group by g.id, l.kkod

enter image description here

2
  • Thank you for the answer, thanks! I apply it to my vectorial layers but the overlap_percentage is equal to NULL. Do you have any advice about this issue?
    – Rinot
    Sep 4, 2022 at 16:07
  • Just providing a comment that might help if you're not familiar with SQL or ST_geometry. Above where @BERA has g.id and l.kkod, replace id with a column name from Vector B and replace kkod with a column name from Vector A. DO NOT CHANGE g.geometry or l.geometry. Replace 'grey' with the name of Vector B and 'levels' with the name of Vector A. More info here: desktop.arcgis.com/en/arcmap/10.3/manage-data/…
    – greyhug
    Jan 11, 2023 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.