[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] Distance between points
From:       Stephen Woodbridge <woodbri () swoodbridge ! com>
Date:       2011-08-29 5:16:33
Message-ID: 4E5B20B1.4060005 () swoodbridge ! com
[Download RAW message or body]

select id, distance_sphere(setsrid(makepoint(-71.112678, 42.331002), 
4326), setsrid(makepoint(longitude, latitude), 4326)) as dist_meters 
from places;

If you are looking for great circle distances the maybe using geography 
instead of geometry type would work better.

-Steve W

On 8/28/2011 1:22 PM, Marcelo Pereira wrote:
> Hello Everybody,
>
> I have got a very simple question about distance between two points:
>
> I have the following table:
>
>     CREATE TABLE places (
>         id   SERIAL,
>         latitude  DOUBLE PRECISION,
>         longitude DOUBLE PRECISION
>     );
>
>
> with the following content:
>
> geo=# SELECT * FROM places;
>   id | latitude  | longitude
> ----+-----------+------------
>    1 | 42.331002 |  -71.112678
>    2 | 42.335158 |  -71.102464
>    3 | 33.911400 | -116.768000
>    4 | 40.415748 |   -3.707135
>    5 | 35.684750 |  139.751158
> (5 rows)
>
> I would like to know the distance between "one fixed point" (42.331002
> -71.112678) and all points in this table.
>
> Simple like this!! Could someone help me?
>
> For now, I don't need to considere zones!! I just need to compare "one
> point" against all points in the table!!
>
> Thanks in advance,
> Marcelo
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic