[postgis-users] st_distance_sphere usage

Paragon Corporation lr at pcorp.us
Fri Feb 21 14:20:53 PST 2014


Mike,
You have your coordinates backwards.  It's longitude,latitude not latitude,
longitude
 
select st_distance_sphere(
    st_setsrid(st_makepoint(-82.60, 33.44), 4326),  -- location near
Warrenton, GA
    st_setsrid(st_makepoint(-82.517, 33.533 ), 4326) -- locaton near
Thomson, GA
);

12891.373014397  meters
 
 
select st_distance_sphere(
    st_setsrid(st_makepoint(-82.60, 33.44), 4326),  -- location near
Warrenton, GA
    st_setsrid(st_makepoint(-97.361, 32.819), 4326) -- location near Forth
Worth, TX
)

 
 
1,375,107.45231354 meters 
 
Hope that helps,
Regina
http://www.postgis.us
http://postgis.net
  _____  

From: postgis-users-bounces at lists.osgeo.org
[mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Michael shutt
Sent: Friday, February 21, 2014 5:05 PM
To: postgis-users at lists.osgeo.org
Subject: [postgis-users] st_distance_sphere usage


I am working with PostgreSQL v9.1.11 and PostGIS 2.1.0.  I am trying to use
st_distance_sphere to calculate the distance between various points and am
getting results that don't make sense.  According to the documentation, that
function should return the distance in meters between the 2 points supplied.
Here are two examples that demonstrate the issue I am having:

select st_distance_sphere(
    st_setsrid(st_makepoint(33.44, -82.60), 4326),  -- location near
Warrenton, GA
    st_setsrid(st_makepoint(33.533, -82.517), 4326) -- locaton near Thomson,
GA
)

returns 9325.862 meters, or 5.8 miles, which seems correct

select st_distance_sphere(
    st_setsrid(st_makepoint(33.44, -82.60), 4326),  -- location near
Warrenton, GA
    st_setsrid(st_makepoint(32.819, -97.361), 4326) -- location near Forth
Worth, TX
)

returns 9873.560 meters, or 6.1 miles, which ain't even close.

I have read and re-read the PostGIS docs and can't find anything I am doing
wrong.  Is that function misbehaving or am I using it incorrectly?

Thanks in advance

Mike

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


More information about the postgis-users mailing list