I am looking for a QGIS expression in Field Calculator that delivers the values "good", "medium" and "bad", depending on the percentage that the geometry of features in Layer 1 (red polygons) intersect with the geometry of feature-class A (green polygon) or feature-class B (yellow polygon) of Layer 2.
If the geometry of Layer 1 features intersects more than 50% with feature-class A geometry of Layer 2, it should be "good", if more then 50% with feature class B geometry of Layer 2 it should be "medium", else "bad".
I tried the following expression but it delivered "bad" for all features":
CASE
WHEN area(intersection(geometry(get_feature('layer 2', 'feature-class', '1')),$geometry)) / $area > 0.5
THEN 'good'
WHEN area(intersection(geometry(get_feature('layer 2', 'feature-class', '2')),$geometry)) / $area > 0.5
THEN 'medium'
ELSE 'bad'
END
Do you know what the right expression would be?