[Ottawa_users] Lat Long Calculations

Frank Warmerdam warmerdam at pobox.com
Wed Jun 27 09:59:45 EDT 2007

Sampson, David wrote:
> Hey folks,
> I'm looking for a library (with python bindings?) or the equations with
> explanations to calculate the distance between two points. Specifically
> the points are lat/long in decimal degrees.
> YES! There are loads of calculators online but this is for inclusion
> into an application. So I am looking for the equation that make these
> calculators tick.
> I have looked in many areas but am either not understanding what modules
> or libraries have to offer or I am missing the obvious?
> Is there anything in PROJ/GEOS/OGR etc etc?


There are two approaches to computing the distances between lat/long points.

One is to compute great circle distances on the ellipsoid.  The PROJ.4
geod command can be used for this.  Ignoring hills and such this is a
very accurate way of computing the distances.

For reasonably local regions (distances of 100's of kilometers but
not thousands say) you can also get good results by converting the
points into an appropriate local projection and computing the distance
in that projection.  This can be accomplished with normal projections
support including the osr.CoordinateTransformation stuff in the GDAL/OGR
Python bindings.

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org

More information about the Ottawa_users mailing list