<HTML dir=ltr><HEAD><TITLE>Re: [postgis-users] Buffer select from one layer to another?</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2900.3314" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText57821 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>Abe,</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>David's is close but doesn't use an index</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2>Try</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>SELECT  h.* FROM  houses h, </FONT><FONT size=2>roads r </FONT></DIV>
<DIV dir=ltr><FONT size=2>where r.gid=1663 and  ST_DWithin(h.the_geom, r.the_geom, 500)</FONT></DIV><FONT size=2></FONT></DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr><FONT size=2>(although the above really translates to < 500 instead of <= 500)</FONT></DIV>
<DIV dir=ltr><FONT size=2></FONT> </DIV>
<DIV dir=ltr><FONT size=2>Hope that helps,</FONT></DIV>
<DIV dir=ltr><FONT size=2>Regina</FONT></DIV>
<DIV dir=ltr><BR></DIV>
<DIV dir=ltr>
<HR tabIndex=-1>
</DIV>
<DIV dir=ltr><FONT face=Tahoma size=2><B>From:</B> postgis-users-bounces@postgis.refractions.net on behalf of David William Bitner<BR><B>Sent:</B> Wed 6/11/2008 2:08 PM<BR><B>To:</B> PostGIS Users Discussion<BR><B>Subject:</B> Re: [postgis-users] Buffer select from one layer to another?<BR></FONT><BR></DIV>
<DIV>
<P><FONT size=2>Abe --<BR><BR>For this type of query, running a buffer is actually not necessary.<BR><BR>select h.* from houses h,roads r where r.name like '%MAIN%' and<BR>distance(h.the_geom,r.the_geom)<=500;<BR><BR>David<BR><BR>On Wed, Jun 11, 2008 at 12:54 PM, Abram Gillespie<BR><abe.gillespie.lists@gmail.com> wrote:<BR>> Hi All,<BR>><BR>> I'm finally starting to do some real production work ... after years<BR>> of simply using PostGIS in example scenarios as I developed zigGIS.<BR>> Pretty funny, actually.  Anywho, could someone enlighten me on how to<BR>> buffer a road and return the surrounding buildings?  This is what I<BR>> have so far:<BR>><BR>> select h.* from houses h,roads r where r.name like '%MAIN%' and<BR>> touches(h.the_geom, buffer(r.the_geom,500));<BR>><BR>> Now I realize the above is a bit complex since " like '%MAIN%' "<BR>> returns multiple road segments, but even working on a single road:<BR>><BR>> select h.* from houses h,roads r where r.gid=1663 and<BR>> touches(h.the_geom, buffer(r.the_geom,500));<BR>><BR>> doesn't seem to return anything.  I'm positive the buffer query should<BR>> return some houses.<BR>><BR>> Thanks for any help!<BR>><BR>> -Abe<BR>> zigGIS Team<BR>> Obtuse Software, <A href="http://www.obtusesoft.com/">http://www.obtusesoft.com</A><BR>> _______________________________________________<BR>> postgis-users mailing list<BR>> postgis-users@postgis.refractions.net<BR>> <A href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>><BR><BR><BR><BR>--<BR>************************************<BR>David William Bitner<BR>_______________________________________________<BR>postgis-users mailing list<BR>postgis-users@postgis.refractions.net<BR><A href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR></FONT></P></DIV></BODY></HTML>
<HTML><BODY><P><hr size=1></P>
<P><STRONG>
The substance of this message, including any attachments, may be confidential, legally privileged and/or exempt from disclosure pursuant to Massachusetts law. It is intended solely for the addressee. If you received this in error, please contact the sender and delete the material from any computer.
</STRONG></P></BODY></HTML>

<P><hr size=1></P>
<P><STRONG><font size="2" color="339900"> Help make the earth a greener place. If at all possible resist printing this email and join us in saving paper. </p> <p> </font></STRONG></P>