On 3/29/2010 9:58 PM, Stephen Woodbridge wrote:
If you have a POINT then you can find the closest centerline within some RADIUS with:

select *, distance(POINT, the_geom) as dist
  from lines
 where expand(POINT, RADIUS) && the_geom
 order by dist limit 1;

-Steve

Or to find the closest centerline for all points in your point table:

SELECT DISTINCT ON (a.gid) a.*, b.*, ST_Distance(a.geom, b.geom) AS dist
FROM points a, lines b
WHERE ST_Expand(a.geom, RADIUS) && b.geom
ORDER BY a.gid, dist ASC;

Cheers,
Kevin
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to