[postgis-users] Finding Points with distance to a location.
Nicolas Ribot
nicky666 at gmail.com
Tue Jan 2 01:23:14 PST 2007
> SELECT
> location_id,
> distance_spheroid (
> point_geom,
> SetSRID(MakePoint(-117.12538, 32.6857),4326),
> 'SPHEROID["WGS_1984",6378137,298.257223563]'
> )
> FROM
> locations
> ORDER BY
> distance_spheroid(
> point_geom,
> SetSRID( MakePoint( -117.13538, 32.6857 ), 4326 ),
> 'SPHEROID["WGS_1984",6378137,298.257223563]'
> )
>
>
You can even give an alias name to your distance_spheroid column (with
the "as <col_name>" syntax) in order to make your query more readable:
SELECT
location_id,
distance_spheroid (
point_geom,
SetSRID(MakePoint(-117.12538, 32.6857),4326),
'SPHEROID["WGS_1984",6378137,298.257223563]'
) as dist
FROM
locations
ORDER BY dist;
Nicolas
More information about the postgis-users
mailing list