AW: [postgis-users] Overlaps query
Robert Coup
robert.coup at onetrackmind.co.nz
Fri May 25 01:14:00 PDT 2007
Thorsten Kraus wrote:
>
> Thanks for your answer. I have tried this before.
>
> SELECT COUNT(a.id) FROM tbl1 a, tbl1 b WHERE a.geom && b.geom and a.id
> <> b.id
>
> But the result differs from my other query. Regarding to the PostGIS
> doc at http://postgis.refractions.net/docs/ch06.html the && operator
> does not check the spatial overlap of two geometries, it checks if the
> bounding boxes of thw geometries overlap. But in my case I need to
> check if two geometries spatially overlap. Perhaps there is a
> possibility to make this faster in some way.
>
Try combing the two together - Postgis can use the spatial index to find
the overlapping bounding boxes, then use the overlaps function to do an
exact check.
SELECT COUNT(a.id)
FROM tbl1 a, tbl1 b
WHERE a.geom && b.geom
AND a.id <> b.id
AND OVERLAPS(a.geom, b.geom)
Rob :)
--
One Track Mind Ltd.
PO Box 1604, Shortland St, Auckland, New Zealand
Phone +64-9-966 0433 Mobile +64-21-572 632
Web http://www.onetrackmind.co.nz
More information about the postgis-users
mailing list