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

Stephen Sample ssample at nppa.org
Tue Aug 18 06:38:53 PDT 2009


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, <ssample at nppa.org>




More information about the postgis-users mailing list