Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to find out the nearest point on my road network which is a multiline string from a point with lat lon value. I have tried the following codes but it giving a error message that my road network is not a line.

SELECT ST_AsText(ST_Line_Interpolate_Point(foo.the_line, ST_Line_Locate_Point(foo.the_line, ST_GeomFromText('POINT(90.402 23.752)'))))
FROM (SELECT ST_GeomFromText(geom) As the_line from roads) As foo;

Where geom is my geometry column with multiLineString
roads is the table name
Long 90.402 and Lat 23.752
Projected Coordinate system UTM_Zone_46N

share|improve this question

2 Answers

How about just using ST_ClosestPoint?

SELECT ST_AsText(ST_ClosestPoint(
    ST_GeomFromText('MULTILINESTRING ((10 10, 40 50), (20 20, 50 20, 50 60, 20 20))'),
    ST_GeomFromText('POINT(20 40)')
));

http://postgis.net/docs/manual-1.5/ST_ClosestPoint.html

share|improve this answer

To my knowledge you cant. MULTILINESTRING does not quarantee that your LINE is collection of continous LINES. Your query works if you can change your multilines to linestrings ( you can use ST_LineMerge())

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.