[postgis-users] Difficult Problem with Polygons

Mike Toews mwtoews at gmail.com
Mon Oct 29 02:15:31 PDT 2012


On 29 October 2012 21:33, Ed Linde <edolinde at gmail.com> wrote:
> Hi All,
> I need help with 2 hard problems. I store triangles in a table as POLYGON.
>
> 1. I want to know for a given triangle, which triangles share an edge
> (adjacent) with this triangle.

Sounds like you have a finite element mesh with nodes and elements.
You can use ST_Relate with pattern 'FF2F11212' to pick out elements
that share the same edge. This DE-9-IM is sort-of a custom ST_Touches,
but only takes linear boundary overlaps. So if you have a table
"elements", and you want to find ones that touch ID 567:

SELECT elements.*
FROM elements, elements as e
WHERE e.id = 567 AND
    ST_Relate(elements.geom, e.geom, 'FF2F11212');

I'm not certain about your second question.

-Mike



More information about the postgis-users mailing list