Using postgis I am trying to find polygons that intersect, ignoring polygons that only have a shared boundary (edge).

  1. ST_Relate(g1, g2, 'T********') is a standard intersection.
  2. ST_Relate(g1, g2, 'TF*F*****') standard intersection with boundary touching false

An image of what I am trying to achieve (from: http://daniel-azuma.com/articles/georails/part-6):

enter image description here

I am confident in the underlying geometries as they are created inside of postgis by taking the overlay similar to here.

Similar to: postgis st_relate polygon inside another and sharing a boundary though I want to ignore cases where the only topological connection is the boundary.

  • 1
    I never used ST_Relate(), but I should try. But I'm lazy, so I'd just go with ST_Intersects() AND NOT ST_Touches() ... ;-)
    – pLumo
    Mar 8, 2018 at 10:19
  • I should test, but I believe that ST_Relate is problematic for the query planner, so Intersects and Touches might also be faster.
    – Jay Laura
    Mar 8, 2018 at 15:52

1 Answer 1


Actually the first relation that you list does exclude the Touch relation, and maybe exactly what you want: ST_Relate(g1, g2, 'T********').

The regular Intersects relation cannot be represented as a single D9IM. But the opposite of the Intersects - the Disjoint can be represented as 'FF*FF****'.

So if you want to exclude the Touch, use 'T********'. But maybe you want the Overlaps relation? That is, maybe you want to exclude the Contains and Within as well, then use 'T*T***T**'. It does not allow one polygon to be contained inside of another.

Both 'T********' and 'T*T***T**' allow only the right of the two configurations on your illustration.

  • It looks like my assumption that 'geometries are good' is actually wrong! Performing the initial overlay analysis I have overlaps with areas (in latl/lon space) that are 1e-17; looks like floating point issues! So 'T********' is spot on assuming the geoms are good.
    – Jay Laura
    Mar 8, 2018 at 15:51

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.