[postgis-users] Great circle as a linestring

Colin Wetherbee cww at denterprises.org
Fri Feb 22 10:10:02 PST 2008

Dane Springmeyer wrote:
> Okay, I've got a bit closer. The right way to do this is likely a 
> function that computes the route between two points borrowing from some 
> of the formulas here:
> http://williams.best.vwh.net/avform.htm#Crs The postgis function that 
> calculates the great circle distance is likely engineered this way, but 
> we'll have to hear from the experts on that.

Thanks for your thorough investigation.  I've just solved it!  Here's my 

The idea is to take points on the sphere, make the line there, 
segmentize the line, and then transform it to the plane.

       Transform(dp.location, 53027),
       Transform(ap.location, 53027)
     ), 4000
   ), 4326
) AS line

The 4000 is an arbitrary "distance" I conjured up.  I don't really know 
what the units are, but 20 was too low and thrashed my server for a few 
minutes before I killed the process.

The problem with our previous approach was we didn't do it with 
segments... when the segments are reprojected, they stay more-or-less 
aligned along the sphere.

Thanks again. :)


More information about the postgis-users mailing list