I have two separate polygon layers, A and B, of which I want to calculate the intersection to union ratio and store it as an attribute to polygon A. To do this, one needs to divide the area of the intersection over the area of the union, like this (in pseudo-code): area(intersection(PolyA, PolyB)) / area(union(PolyA, PolyB)).
I am aware that the standard routine would be to first produce the intermediate products (the polygon of intersection, and the polygon of the union), then join their respective areas to Polygon A, and finally calculate the ratio. However, given the possibilities in the Field Calculator, like demonstrated over here, I thought it might be neat to do it all inside the Field Calculator.
I tried the following in the field calculator: area( intersection( @PolyA , @PolyB )) / area( union( @PolyA , @PolyB )), but that resulted in the error: Evaluation error in expression. Cannot convert to geometry.
How do you calculate the intersection to union ratio between two polygons in the Field Calculator in QGIS?
I'm new to QGIS. I use version 3.32 Lima.