<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16788" name=GENERATOR></META></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=585030712-29122008><FONT face=Arial 
color=#0000ff size=2>Why wouldn't you use a nearest neighbor calculation 
as demonstrated here (using DISTINCT ON)?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=585030712-29122008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=585030712-29122008><FONT face=Arial 
color=#0000ff size=2><A 
href="http://postgis.refractions.net/documentation/manual-svn/ST_DWithin.html">http://postgis.refractions.net/documentation/manual-svn/ST_DWithin.html</A></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=585030712-29122008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=585030712-29122008><FONT face=Arial 
color=#0000ff size=2>Keep in mind ST_DWithin and  ST_Distance don't care 
about whether a geometry is a line or polygon or point or collection or 
whatever.  They will always consider the minimum distance between 2 
geometries.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=585030712-29122008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=585030712-29122008><FONT face=Arial 
color=#0000ff size=2>ST_DWithin will use a spatial index where as ST_Distance 
will not.  So for ST_DWithin to work, you have to make the 
assumption,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=585030712-29122008><FONT face=Arial 
color=#0000ff size=2>the closest road to any point is no more than X units 
away.  The bigger you make the X, the less efficient the index search, but 
the less likely you will leave a point out.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=585030712-29122008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=585030712-29122008><FONT face=Arial 
color=#0000ff size=2>Hope that helps,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=585030712-29122008><FONT face=Arial 
color=#0000ff size=2>Regina</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> 
postgis-users-bounces@postgis.refractions.net 
[mailto:postgis-users-bounces@postgis.refractions.net] <B>On Behalf Of 
</B>nicklas.aven@jordogskog.no<BR><B>Sent:</B> Monday, December 29, 2008 3:18 
AM<BR><B>To:</B> postgis-users@postgis.refractions.net<BR><B>Subject:</B> 
[postgis-users] Dividing an area to closest line<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV>Hallo</DIV>
<DIV> </DIV>
<DIV>My first time writing here.</DIV>
<DIV> </DIV>
<DIV>The case is that I need to find the closest road from every point in the 
terrain. The roads are defined in "roadparts". The very best thing would be to 
get polygons around every roadpart which I could use on other data to bind it to 
the right road.</DIV>
<DIV> </DIV>
<DIV>The only solution I can see is making a raster of small rektangels that I 
bind to my roadparts using nearest neighbour-calculations.</DIV>
<DIV> </DIV>
<DIV>My question is if someone has a more efficient and better solution.</DIV>
<DIV> </DIV>
<DIV>Sorry for my bad english</DIV>
<DIV> </DIV>
<DIV>Thanks</DIV>
<DIV>/Nicklas Avén</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>