[postgis-users] ST_Distance_Spheroid gives distance 28 times higher than haversine formula?

2 views
Skip to first unread message

Stephen Sample

unread,
Aug 18, 2009, 9:38:53 AM8/18/09
to postgi...@postgis.refractions.net
I'm in the process of moving a GIS app from manual distance
calculations (using the haversine formula) to PostGIS using
ST_Distance_Spheroid (with WGS84).

The geometry column is just storing longitude/latitude points (in
radians).


The distances I get with ST_Distance_spheroid (and ST_Distance_Sphere)
are just about exactly 28 times as large as the haversine distance,
and I can't figure out where that ratio is coming from.

I initially entered the data with no SRID, but that doesn't make a
difference: I get the same ratio if I enter the data points as WGS84.

It's probably a unit conversion issue, but the ratio isn't a familiar
one.


When I spot-check known locations, the haversine distances are very
close to the real-world values, and the maximum values there match the
range I specify in ST_DWithin.

Any ideas/pointers?


(Mac OS X 10.5.8, PostgreSQL 8.2.4, PostGIS 1.4, GEOS 3.1.1, Proj 4.6.1)


Ta,
-Stephen
-----------------------------------------
Stephen Sample, NPPA IT Manager/Web Developer
+919/383-7246 x11, <ssa...@nppa.org>

_______________________________________________
postgis-users mailing list
postgi...@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Paul Ramsey

unread,
Aug 18, 2009, 9:51:10 AM8/18/09
to PostGIS Users Discussion
On Tue, Aug 18, 2009 at 9:38 AM, Stephen Sample<ssa...@nppa.org> wrote:
> I'm in the process of moving a GIS app from manual distance calculations
> (using the haversine formula) to PostGIS using ST_Distance_Spheroid (with
> WGS84).
>
> The geometry column is just storing longitude/latitude points (in radians).

The *spher(oid) function in postgis expect degrees, not radians.

P.

Stephen Sample

unread,
Aug 18, 2009, 1:58:13 PM8/18/09
to PostGIS Users Discussion

On Aug 18, 2009, at 9:51 AM, Paul Ramsey wrote:

>> I'm in the process of moving a GIS app from manual distance
>> calculations
>> (using the haversine formula) to PostGIS using ST_Distance_Spheroid
>> (with
>> WGS84).
>>
>> The geometry column is just storing longitude/latitude points (in
>> radians).
>
> The *spher(oid) function in postgis expect degrees, not radians.


Ah, ok. That would be it, then. Thanks!


Ta,
-Stephen
-----------------------------------------
Stephen Sample, NPPA IT Manager/Web Developer
+919/383-7246 x11, <ssa...@nppa.org>

_______________________________________________

Reply all
Reply to author
Forward
0 new messages