Overlay_disjoint when used with the [,expression]
parameter will return an array of all polygon that are disjoint from the current feature so unless a polygon intersect all other polygon it will always return something, remove the [,expression] parameter to get a boolean stating if the current feature intersect something or not.
The same is true for all other, you don't need to use the [,expression]
parameter to test the relationship, it is only usefull to get the list of intersecting feature (and using it with $geometry
won't get you that)
In the expression below I use the boolean test first then use the [,expression]
parameter with the name of the polygon to output more informative result like "intersect C" rather than only "intersect" as you did. You may want to split the overlay type and the polygon(s) concerned in two different column rather than putting all in the same place as I did :
CASE WHEN overlay_equals('TEST_c4dd4034_d7cf_40e9_80aa_a5cc8ec77157') THEN 'equals'|| '' ||array_to_string(overlay_equals('TEST_c4dd4034_d7cf_40e9_80aa_a5cc8ec77157', "NAME")) WHEN overlay_touches('TEST_c4dd4034_d7cf_40e9_80aa_a5cc8ec77157') THEN 'touches'|| '' ||array_to_string(overlay_touches('TEST_c4dd4034_d7cf_40e9_80aa_a5cc8ec77157', "NAME")) WHEN overlay_disjoint('TEST_c4dd4034_d7cf_40e9_80aa_a5cc8ec77157') THEN 'Disjoint' WHEN overlay_within('TEST_c4dd4034_d7cf_40e9_80aa_a5cc8ec77157') THEN 'within'|| '' ||array_to_string(overlay_within('TEST_c4dd4034_d7cf_40e9_80aa_a5cc8ec77157', "NAME")) WHEN overlay_contains('TEST_c4dd4034_d7cf_40e9_80aa_a5cc8ec77157') THEN 'contains'|| '' ||array_to_string(overlay_contains('TEST_c4dd4034_d7cf_40e9_80aa_a5cc8ec77157', "NAME")) WHEN overlay_intersects('TEST_c4dd4034_d7cf_40e9_80aa_a5cc8ec77157') THEN 'intersect'|| '' ||array_to_string(overlay_intersects('TEST_c4dd4034_d7cf_40e9_80aa_a5cc8ec77157', "NAME")) ELSE 'no_overlap'END
Note that the ELSE 'no_overlap'
is never used as the overlay_disjoint
take care of that case...
Also as CASE statement are read and evaluated sequentially if a polygon touch one polygon and intersect a third one the output will be "touches" but not "intersect" (as overlay_touches came before overlay_intersects in the expression it will be evaluated first and this will be the only result you get, see polygon L,M and N below) so you may want to order the different overlay_xxxxx in a way that give you the relation that you judge the most important first.