[postgis-users] Spatial Query

Paragon Corporation lr at pcorp.us
Thu Aug 14 03:03:29 PDT 2008

Have you tried
SELECT a.gid, a.the_geom
FROM a INNER JOIN b ON (b.gid = 100 AND ST_DWithin(a.the_geom, b.the_geom,1)
WHERE NOT ST_Within(a.the_geom, b.the_geom)
Hope that helps,


From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Brian
Sanjeewa Rupasinghe
Sent: Thursday, August 14, 2008 5:53 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] Spatial Query

I have polygon features in PostgreSQL database. How can i make
a query to find all polygons that are within a distance of say 1m from
polygon id = 100. Query should not select polygons that are within polygon
id = 100.
I used ST_WIthindistance, but it selcted all insidepolygons too. Please
help me if you have any sample code or clue.
Thanks in advance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080814/be37d668/attachment.html>

More information about the postgis-users mailing list