<table cellspacing="0" cellpadding="0" border="0"><tr><td valign="top" style="font: inherit;"><p>Hi Chris</p>
<p>You need an inner query that selects the closest line segment and use that geometry in the shortest line query <br>
Select shrtest line(p.the_geom,nearestgeom.thegeom) from<br>
Points p,<br>
Select a.*, st_distance(a.the_geom, b.the_geom) as dist from roads a,points b order by dist asc limit 1) as nearestgeom</p>
<p>Hope this is readable as sending from phone.</p>
</td></tr></table> <div id="_origMsg_">
<div style="font-family:arial, helvetica, sans-serif:font-size:10pt">
<br />
<div style="font-family:times new roman, new york, times, serif;font-size:12pt">
<font size="2" face="Tahoma">
<hr size="1">
<b>
<span style="font-weight:bold;">From:</span>
</b>
Chris English <sglish@hotmail.com>; <br>
<b>
<span style="font-weight:bold:">To:</span>
</b>
<postgis-users@postgis.refractions.net>; <br>
<b>
<span style="font-weight:bold:">Subject:</span>
</b>
[postgis-users] ST_ShortestLine(r.geom, m.geom) confusion - limiting point to nearest line results <br>
<b>
<span style="font-weight:bold;">Sent:</span>
</b>
Mon, Nov 21, 2011 9:00:47 PM <br>
</font>
<br>
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td valign="top" style="font:inherit;"><div dir='ltr'>
<style><!--
.hmmessage P
{
margin:0px;padding:0px;}
body.hmmessage
{
font-size:10pt;font-family:Tahoma;}
--></style>
<div dir="ltr">Hi all,<div><br></div><div>My goal is to model electric distribution in a municipality with 8.4, PostGis 1.5 and pgrouting.</div><div><br></div><div>I clipped roads and parcels from state level (roads) and county level (parcels) to get roads and parcels for</div><div>a municipality resulting in two tables:</div><div><br></div><div>summit_roads (306 rows) and summit_parcels (6874 rows) . </div><div>The roads table generally conforms to the layout of electric distribution.</div><div>I then extracted a centroids table from parcels to try to develop the 'final drop' line segment, the last bit of wire from</div><div>distribution wire (roads) to a home or business with the final goal to then join to final drop to roads for end to end distribution.</div><div><br></div><div><div><br></div><div>explain </div><div>create table summit_final_drop as</div><div>select Distinct ST_ShortestLine(r.intersection_geom, m.geom) as
final_drop_geom,</div><div>r.sld_name,</div><div>r.measured_l,</div><div>m.pams_pin,</div><div>m.mun,</div><div>m.block,</div><div>m.lot,</div><div>m.qcode</div><div>from summit_roads as r,</div><div>summit_parcels_centroid as m;</div></div><div><br></div><div>This code resulted in 2,109,000 rows , essentially centroid to every line point as against what</div><div>I was expecting.</div><div><br></div><div>Suggestions appreciated.</div><div><br></div><div>Thanks,</div><div>Chris</div></div>
</div></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>