[Ottawa_users] Lat Long Calculations

Sampson, David dsampson at NRCan.gc.ca
Wed Jun 27 13:47:22 EDT 2007

Thanks Frank,

I was looking into maybe doing a projection to UTM, but I fear problems
when a distance is calculated across two different UTM zones... Does
this matter?

I have been looking for explanations of great circle distances.

Wikipedia presents some interesting equations but intepriting them intoo
a code structure is confusing a bit.

I found a website that has a calculator (same old same old) but then
provides a snipet of perl script code for calculating the values

The challenge here is I believe this perl code is a geographic
measurement, not great circle.

I looked at PCL (python cartographic library) but there does not seem to
be any such measurements between two points.

I looked at GEOS and found that there are measurements between geometry
But getting into the GEOS library from python is proving a challenge.
Some posts even note that the measure function is not exposed to the C
API of Geos (FRANK?)

So what about the measuremnt function from PCL?  Well I am having to
battle PCL install on windows using FWTools. If this works I hope this
is even what I want. Furthermore I hope I can compile and package up an
application without an FWTOOLS dependency.

I would have thought someone would have a compas.py program that would
do all this, but I guess it's so simple that everyone reinvents their
own wheel when they need it. My chissel is not that precise to carve a
new wheel. (SMILE)

Thanks for the thoughts, keep me posted is any other ideas pop up.


-----Original Message-----
From: ottawa_users-bounces at lists.osgeo.org
[mailto:ottawa_users-bounces at lists.osgeo.org] On Behalf Of Frank
Sent: June 27, 2007 10:00
To: Ottawa (Canada) Local Chapter List
Subject: Re: [Ottawa_users] Lat Long Calculations

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

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

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,

Ottawa_users mailing list
Ottawa_users at lists.osgeo.org

More information about the Ottawa_users mailing list