Thank you very much.

 

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rodrigo Martín 
LÓPEZ GREGORIO
Sent: Wednesday, August 15, 2007 5:44 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Extracting a line from multilinestring

 

Hi Brian...

I think you can do one of this things:

1. If you are sure that all your geometries have just one LINESTRING then you 
can do:

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 


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:

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


If you want to verify if all your geometries have just one LINESTRING you can 
try:

SELECT count(*) FROM roads WHERE NumGeometries(the_geom) > 1


This will return the number of MULTILINESTRINGS that have more than one 
LINESTRING 

Rodrigo



On 8/15/07, Peck, Brian <[EMAIL PROTECTED]> wrote:

Hey all,

 

Does anyone if there is a way to extract a line from a MultiLineString?

 

I am trying to make the call

 

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

 

But I get the error

 

ERROR:  line_locate_point: 1st arg isn't a line

 

My 'the_geom' field is filed with MultiLineString data (though only LineString 
in each one).

 

Ex: 

 

select AsText(the_geom) from roads limit 1;

 

                                          astext

------------------------------------------------------------------------------------------

 MULTILINESTRING((-74.4595680236816 40.0301723480225,-74.4591522216797 
40.0302429199219))

(1 row)

 

- Brian Peck


_______________________________________________
postgis-users mailing list
[email protected] 
http://postgis.refractions.net/mailman/listinfo/postgis-users

 

_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to