[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)


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



-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
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:
Sent from the PostGIS - User mailing list archive at Nabble.com.

postgis-users mailing list
postgis-users at postgis.refractions.net

More information about the postgis-users mailing list