[postgis-users] convert distances to kilometers

Rich Gibson rich at testingrange.com
Mon Jan 31 11:23:34 PST 2005


This query calculates the distance in meters between two points:

select distance_spheroid(
GeometryFromText('POINT(-122.8412 38.4112)', 4326),
GeometryFromText('POINT(-122.4750 37.8073)', 4326),
'SPHEROID["WGS_1984",6378137,298.257223563]'
 )  

So this is the distance in km:
select distance_spheroid(
GeometryFromText('POINT(-122.8412 38.4112)', 4326),
GeometryFromText('POINT(-122.4750 37.8073)', 4326),
'SPHEROID["WGS_1984",6378137,298.257223563]'
 )  / 1000

This is (close to) the distance in miles:
select distance_spheroid(
GeometryFromText('POINT(-122.8412 38.4112)', 4326),
GeometryFromText('POINT(-122.4750 37.8073)', 4326),
'SPHEROID["WGS_1984",6378137,298.257223563]'
 )  / 1609.344


On Mon, 31 Jan 2005, Ednardo Ferreira wrote:

> 
> Hi,
> 
> I'm calculating distances from 2 geometries using postgis functions. The distances are cartesians. How can I convert this distances to kilometers or miles?
> 
> Thanks!
> 
>  
> 
> 
> 
> "Eterno é tudo aquilo que dura uma fração de segundo, mas com tamanha intensidade que se petrifica, e nenhuma força jamais o resgata."
> 
> Drummond
> 		
> ---------------------------------
> Do you Yahoo!?
>  Yahoo! Search presents - Jib Jab's 'Second Term'



More information about the postgis-users mailing list