[postgis-users] Finding Points with distance to a location.

Adam adam at spatialsystems.org
Fri Dec 29 22:07:05 PST 2006


I figured this out last year, but can't figure out how I figured it out.  I've read "Mapping Hacks" and "Web Mapping Illustrated" along with what I could find in the WIKI and documentation but can't start to figure it out.

I have my geometry column named "point_geom" and a unique column named "location_id".

I want to query the distance of all the points in my "point_geom" column to coords:  Long = -117.13538 :: Lat = 32.6857

What would the query for this look like?  Is there a comprehensive article or book out that goes in depth into how spatial queries work?

The output would look like this:

location_id | distance
-------------------------------
5 | 45.38823
9 | 50.39952
1 | 82.39923
.
.
.
-------------------------------


I'm guessing that you'd use distance_spheroid for the calculation.     

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20061230/8b0980ee/attachment.html>


More information about the postgis-users mailing list