[postgis-users] Point in Polygon query tolerance?

Frank Broniewski liste at geo-dienstleistung.de
Sun Aug 5 03:00:28 PDT 2007


Am Samstag, 4. August 2007 schrieb Michael Fuhr:
> On Sat, Aug 04, 2007 at 12:20:32PM +0200, Frank Broniewski wrote:
> > To my problem: I have a geology polygon table and a site point table. Now
> > I want to find out the site's geology. I do the following query
> >
> > SELECT name FROM geo.geology AS c, arch.operation AS p WHERE c.the_geom
> > && p.op_centroid AND p.op_id = 20
> >
> > for a single sample site. The query returns three rows, while it should
> > be just one. Another site returns even five rows as result.
>
> The && operator is a fast check for bounding box overlaps that can
> take advantage of indexes.  You'll need to restrict the result set
> further by adding a more expensive test like one of the following:
>
> contains(c.the_geom, p.op_centroid)
> within(p.op_centroid, c.the_geom)
> intersects(c.the_geom, p.op_centroid)
> distance(c.the_geom, p.op_centroid) = 0

Thanks alot for your tip, now I get the correct results. One more thing 
though. I was looking for operators like contains and such already, but I 
wasn't able to find them literally in the manual. Am I correct, when I assume 
that these operators are listed in Chapter 6 and have a "ST_" prefix ( 
http://postgis.refractions.net/docs/ch06.html )? Because my postgis version 
does not know them. But since I installed postgis on my ubuntu machine using 
apt-get, I presume I have a quite outdated version.

Best whishes

Frank

-- 
Softwaredienstleistungen

Frank Broniewski
Cloefstraße 76a
66693 Mettlach

Email: frank at geo-dienstleistung.de
WWW: http://www.geo-dienstleistung.de/

Telefon: 06865 / 911 040



More information about the postgis-users mailing list