[postgis-users] select point in linestring

Paragon Corporation lr at pcorp.us
Thu Jan 29 23:33:59 PST 2009

```Not clear what you are trying to do.  A line is represented by a set of
points, but in theory it has an infinite number of points.

So are you
1) Trying to get one of the points that is used to represent the line  - you
have a line -- someone clicks somewhere on it, and you want
To get the closest point that is part of the representation of the line
I suppose you could do

SELECT P.gid, P.path[1] As pos, P.geom As pclosest
FROM (SELECT gid, (ST_Dump(the_geom)).*
FROM point_table) As P
WHERE ST_Dwithin(P.geom, ST_SetSRID(ST_MakePoint(lon,lat),somesrid), 0.01)

--0.01 you can replace with some other tolerance number to compensate for
the fact that a person probably won't click right on the line
(the path I think will give you the index position of the point on the line)

http://postgis.refractions.net/documentation/manual-svn/ST_Dump.html

2) Or get a position on the line using some feature such as street address
etc.
For this you'd use the line interpolation functions or possibly
ST_intersects

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

Leo

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
searchelite
Sent: Thursday, January 29, 2009 11:46 PM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] select point in linestring

Dear All, I have a linestring that constructed from many points, my question
is how can i identify(select) one of the point from the linestring. I know
there is ST_POINTN(geometry,integer) that Return the N'th point in the first
linestring in the geometry. But with ST_POINTN, i have to know the number of
the points in order to return the geometry of the points. is there any other
function beside ST_POINTN that can return point geometry without have to
know the index number of the points?

I hope all of you can understand my question..thank you in advance
--
View this message in context:
http://www.nabble.com/select-point-in-linestring-tp21741396p21741396.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

```