<!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=617093312-29122008><FONT face=Arial
color=#0000ff size=2>Nicklas,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=617093312-29122008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=617093312-29122008><FONT face=Arial
color=#0000ff size=2>Hmm still don't quite understand. What do these road
parts look like? Do you have geometries at all for them? Are they
line strings or points?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=617093312-29122008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=617093312-29122008><FONT face=Arial
color=#0000ff size=2>Perhaps if you provide a sample like The ST_AsText
representation of one that would help us a bit to provide more useful
suggestions.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=617093312-29122008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=617093312-29122008></SPAN><FONT face=Arial><FONT
color=#0000ff><FONT
size=2>If you are trying to make polygons of X width out of road line strings, then <SPAN
class=617093312-29122008>I have a function lying around somewhere that will
given a linestring -- fatten it up to x thickness (which is pretty much what
ST_Buffer(linestring, x/2) would do for you except my function won't create a
hot dog - rounded edges), it will create a polygon where the centerline is the
original line and edges are perpendicular to the center
line.</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=617093312-29122008></SPAN></FONT></FONT></FONT> </DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=617093312-29122008>Then you can use
</SPAN></FONT></FONT></FONT><FONT><FONT><FONT face=Arial><FONT
color=#0000ff><FONT size=2>S<SPAN class=617093312-29122008>T_Intersects to
figure out which points fall in the road
poly.</SPAN></FONT></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT><FONT><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=617093312-29122008></SPAN></FONT></FONT></FONT></FONT></FONT> </DIV>
<DIV><FONT><FONT><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=617093312-29122008>Hope that
helps,</SPAN></FONT></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT><FONT><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=617093312-29122008>Regina</SPAN></FONT></FONT></FONT></FONT></FONT></DIV>
<DIV><FONT><FONT><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=617093312-29122008></SPAN></FONT></FONT></FONT></FONT></FONT> </DIV>
<DIV><FONT><FONT><FONT face=Arial><FONT color=#0000ff><FONT size=2><SPAN
class=617093312-29122008></SPAN></FONT></FONT></FONT></FONT></FONT> </DIV>
<DIV><BR></DIV>
<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 7:28
AM<BR><B>To:</B> PostGIS Users Discussion<BR><B>Subject:</B> RE: [postgis-users]
Dividing an area to closest line<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV> </DIV>
<DIV>Thanks for the answer.</DIV>
<DIV>My problem is that I just have the roadparts and nothing to relate them to.
I would like to create polygons with their borders between the roads so every
possible point inside the polygon share the same closest road. But if it
isnt possible I will have to build a raster of rectangels or just points and use
the method you suggested on them.</DIV>
<DIV> </DIV>
<DIV>/Nicklas<BR><BR>2008-12-29 Obe Regina wrote:<BR><BR>></DIV>
<DIV align=left><SPAN
style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Arial">Why wouldn't you use
a nearest neighbor calculation as demonstrated here (using DISTINCT
ON)?</SPAN></DIV>>
<DIV align=left><SPAN
style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Arial"></SPAN> </DIV>>
<DIV align=left><SPAN
style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Arial"><A
href="http://postgis.refractions.net/documentation/manual-svn/ST_DWithin.html">http://postgis.refractions.net/documentation/manual-svn/ST_DWithin.html</A></SPAN></DIV>>
<DIV align=left><SPAN
style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Arial"></SPAN> </DIV>>
<DIV align=left><SPAN
style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Arial">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.</SPAN></DIV>>
<DIV align=left><SPAN
style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Arial"></SPAN> </DIV>>
<DIV align=left><SPAN
style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Arial">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,</SPAN></DIV>>
<DIV align=left><SPAN
style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Arial">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.</SPAN></DIV>>
<DIV align=left><SPAN
style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Arial"></SPAN> </DIV>>
<DIV align=left><SPAN
style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Arial">Hope that
helps,</SPAN></DIV>>
<DIV align=left><SPAN
style="FONT-SIZE: 10pt; COLOR: #0000ff; FONT-FAMILY: Arial">Regina</SPAN></DIV><BR>>>
<DIV align=left>
<HR>
<SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"><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>></SPAN><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>