[postgis-users] Re: intersects(), touches(), overlaps() documentation issue

Michael Fuhr mike at fuhr.org
Tue Mar 7 14:54:23 PST 2006

On Tue, Mar 07, 2006 at 09:46:37AM -0800, Amit Kulkarni wrote:
> I have uploaded the .shp here, and have stripped it of any identifying
> columns (I had to), but have included the .prj file just in case...

Here's a query against that data:

SELECT AsText(Intersection(a.geom, b.geom))
FROM foo AS a, foo AS b
WHERE a.id2 = 27 AND b.id2 = 28;
 POINT(-90.8975547755882 30.5353444824697)
(1 row)

The intersection is an end point of one geometry so Touches should
be true, Overlaps should be false, and Intersects should be true
(Intersects means not Disjoint).  As Martin Davis suggested, the
lines probably aren't quite parallel; they just look overlapping
when rendered.

> I don't know how to do a relate (a,b) to get the intersection matrix
> for now, am rushed for time for now. Would you send me the actual SQL
> query if possible?

You can call Relate() with two arguments to see the intersection
matrix or with three arguments to test the relationship.  Here's
an example of the former with your test data:

SELECT Relate(a.geom, b.geom)
FROM foo AS a, foo AS b
WHERE a.id2 = 27 AND b.id2 = 28;
(1 row)

For an explanation of the intersection matrix see 2.1.13 Relational
Operators in the OpenGIS Simple Features Specification (99-049).

Michael Fuhr

More information about the postgis-users mailing list