Hi Brian...<br><br>I think you can do one of this things:<br><br>1. If you are sure that all your geometries have just one LINESTRING then you can do:<br><br><div style="margin-left: 40px;"><span style="font-style: italic;">
SELECT line_interpolate_point(GeometryN(the_geom,1),line_locate_point(GeometryN(the_geom,1),PointFromText('POINT(-74.5 40)'))) FROM roads ORDER BY Distance(the_geom,PointFromText('POINT(-74.5 40)')) LIMIT 1
</span><br></div><br>2. If your geometries have more than one LINESTRING but this LINESTRINGS are continuous (i.e. there are no gaps between the LINESTRINGS in a MULTILINESTRING) you can use:<br><br style="font-style: italic;">
<div style="margin-left: 40px;"><span style="font-style: italic;">SELECT line_interpolate_point(LineMerge(the_geom),line_locate_point(LineMerge(the_geom),PointFromText('POINT(-74.5 40)'))) FROM roads ORDER BY Distance(the_geom,PointFromText('POINT(-
74.5 40)')) LIMIT 1</span><br></div><br>If you want to verify if all your geometries have just one LINESTRING you can try:<br><br><div style="margin-left: 40px;"><span style="font-style: italic;">SELECT count(*) FROM roads WHERE 
</span><span class="term"><span style="font-style: italic;">NumGeometries(the_geom) > 1</span></span><br><span class="term"></span></div><span class="term"><br>This will return the number of MULTILINESTRINGS that have more than one LINESTRING
<br><br>Rodrigo<br><br></span><br><div><span class="gmail_quote">On 8/15/07, <b class="gmail_sendername">Peck, Brian</b> <<a href="mailto:brian.peck@lmco.com">brian.peck@lmco.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">









<div link="blue" vlink="navy" lang="EN-US">

<div>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Hey all,</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Does anyone if there is a way to extract a line from a
MultiLineString?</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">I am trying to make the call</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">SELECT line_interpolate_point(the_geom,line_locate_point(the_geom,PointFromText('POINT(-74.5
40)'))) FROM roads ORDER BY Distance(the_geom,PointFromText('POINT(-74.5 40)'))
LIMIT 1</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">But I get the error</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">ERROR:  line_locate_point: 1<sup>st</sup> arg isn't
a line</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">My 'the_geom' field is filed with
MultiLineString data (though only LineString in each one).</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Ex: </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">select AsText(the_geom) from roads limit 1;</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">                                         
astext</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">------------------------------------------------------------------------------------------</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> MULTILINESTRING((-74.4595680236816
40.0301723480225,-74.4591522216797 40.0302429199219))</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">(1 row)</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">- Brian Peck</span></font></p>

</div>

</div>


<br>_______________________________________________<br>postgis-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net
</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br><br>
</blockquote></div><br>