[postgis-users] how to write the sql if i want to find a geometry's d-distance neighbors?
Francis Markham
fmarkham at gmail.com
Sun Sep 12 20:40:10 PDT 2010
Hi Sunpeng,
Definitely use ST_DWithin.
-Francis
On 13 September 2010 06:51, sunpeng <bluevaley at gmail.com> wrote:
> Hi,
> I've the following table,and has created the index on uid and location;
> CREATE TABLE points
> (
> location geometry, //assume it's a 2-dimension point
> uid integer
> )
>
> Now, I've a point P with uid= 12345, and want to find the neighbors which
> are within 20, how to write the sql?Is this right?
> select st_astext(location)
> from points a, points b
> where b.rid = 12345 and ST_DWithin(a.the_geom, b.the_geom, 20)
>
> or use st_buffer? which one is more efficient ?
>
> Thanks!
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100913/e1f8a7a9/attachment.html>
More information about the postgis-users
mailing list