[postgis-users] How to get the nearest point for a given point from a geometry of multilinestring

Paragon Corporation lr at pcorp.us
Sat Aug 1 10:47:07 PDT 2009


Thilani,

The 0.5 means 50%
Use ST_Line_Interpolate_Point also to get the point at 50%

http://postgis.refractions.net/documentation/manual-1.4/ST_Line_Interpolate_
Point.html

 SELECT ST_AsText(ST_Line_Interpolate_Point(l.the_geom,
ST_line_locate_point(l.the_geom, ST_GeomFromText('POINT(50 50)'))))
FROM (SELECT ST_geomFromText('LINESTRING(0 0, 1 1, 2 2, 3 3,
49 49, 51 51, 100 100)') As the_geom) As l;

Leo 

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Thilani
Sent: Saturday, August 01, 2009 3:05 AM
To: postgis-users at postgis.refractions.net
Subject: Re: [postgis-users] How to get the nearest point for a given point
from a geometry of multilinestring


Hi kevin

As you suggested, I tried to find the closest points but it did not worked
for me. May be I need more help from you. This is what I tried,

e.g. 
select ST_line_locate_point(ST_geomFromText('LINESTRING(0 0, 1 1, 2 2, 3 3,
49 49, 51 51, 100 100)'), ST_GeomFromText('POINT(50 50)'))

What I want is to get points 49, 49 and 51, 51 or the percentage of those as
the result. But this returned 0.5 as the result.Can you please help me to
get 49,49 and 51,51 as the result.Can you please explain that by using your
own example.Please feel free to modify above example.

Thanks and Best Regards,
Thilani


Thilani wrote:
> 
> Thanks a lot.I will try with this and let you know the result.
> Thilani
> 
> On Tue, Jul 21, 2009 at 10:43 AM, Kevin 
> Neufeld<kneufeld at refractions.net>
> wrote:
>> If I understand you correctly, you could first find the 2-point line 
>> segment within your multilinestring that is within some tolerable 
>> distance to your intersection point.  The endpoints of the 
>> linesegment would be vertices closest to your intersection point.
>>
>> Here's an old way of extracting the line segments from a linestring 
>> if it helps.
>> http://postgis.refractions.net/pipermail/postgis-users/2008-March/018
>> 734.html
>>
>> Or, use ST_Line_Locate_Point
>> (http://www.postgis.org/documentation/manual-svn/ST_Line_Locate_Point
>> .html) to determine the percentage along your linestring the 
>> intersection point occurs.  Then for every vertex determine their 
>> percentage along to find the two vertices of interest.
>>
>> -- Cheers,
>> Kevin
>>
>>
>> Thilani Imalka wrote:
>>>
>>> We used ST_Intersection function to get the cross point when roads 
>>> are crossing each other. So with the output of this function we have 
>>> the crossing point and now we need to get adjacent points to that 
>>> crossing point from the road (where the road is a geometry of 
>>> multilinestring).Is there any post GIS function to get those 
>>> adjacent points or any combination of functions to get the correct 
>>> output Basically we need to get the nearest point for a given point 
>>> from a geometry of multilinestring.
>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at postgis.refractions.net
>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> 

--
View this message in context:
http://www.nabble.com/How-to-get-the-nearest-point-for-a-given-point-from-a-
geometry-of-multilinestring-tp24569069p24766661.html
Sent from the PostGIS - User mailing list archive at Nabble.com.

_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users





More information about the postgis-users mailing list