[postgis-users] Closest points to positions along a line

Paragon Corporation lr at pcorp.us
Thu Jul 30 00:54:33 PDT 2009


Fred,
 
Still kind of unclear to me what you are trying to do.
 
It sounds like you either want to use ST_DWithin or one of the linear
referencing functions or maybe both.  Here are some links that might be
useful.
 
http://postgis.refractions.net/documentation/manual-1.4/ST_DWithin.html
(ST_DWithin works with lines, polygons, points etc. and returns if the
minimum distance is within the distance specified)
 
http://postgis.refractions.net/documentation/manual-1.4/ST_Line_Interpolate_
Point.html
 
Here is an interesting use of the interpolate to find closest point on a
line
http://selectoid.wordpress.com/2009/02/13/reprojecting-snapping-point-geomet
ries-onto-a-given-line-geometry-using-postgis/
 
combo use of interpolate and dwithin
http://blog.cleverelephant.ca/2008/04/snapping-points-in-postgis.html
 
Hope that helps,
Regina
 
 
 

  _____  

From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Thurber,
Fred
Sent: Wednesday, July 29, 2009 9:15 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] Closest points to positions along a line


I am a newbie to PostGIS and have a spatial question.
 
We have a geographical straight line with equidistant positions along the
line.  We need to find the closest point for each position on the line.
 
I suppose that the obvious way to do this is to solve the closest point
problem for each position on the line, but I cannot find an easy way to do
this in PostGIS. I could "ORDER BY distance" and limit the results to 1.  To
prevent a full table search I suppose I could limit the search to an
overlapping BOX2D (if there are no matches, I could use the expand function
on the box until I find a match).  Is there a better way to do this?
 
Is there a way to solve this problem in one step?  I am tempted to draw a
box around the whole line and return all the points in a subquery then do
the distance queries on that result, but I am not sure I can do such a query
in SQL.
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090730/2dac6a1d/attachment.html>


More information about the postgis-users mailing list