[postgis-users] query question

Maxime van Noppen maxime at altribe.org
Wed Nov 4 03:56:03 PST 2009


G. van Es wrote:
> I want to have a list of wich geometry of a certain type is touching or crossing another type.
> 
> Can someone point me in the right direction?

Hi,

If I understand your problem you want to find for each geometry in your
table which geometries intersect with it ?

This can be done with the ST_Intersects function and an self-join.
Something like :

SELECT t1.type, t2.type FROM T t1, T t2 WHERE t1.type != t2.type AND
ST_Intersects(t1.the_geom, t2.the_geom);

This will generate an output like :

t1.type | t2.type
-----------------
13      | 12
13      | 1
13      | 4
12      | 3
12      | 8
...

-- 
Maxime



More information about the postgis-users mailing list