Problem Description
Here's a little program that estimates the
surface distance between two points on earth defined by their latitude and
longitude.
Background & Techniques
A viewer recently requested this facility which happened to pique my
curiosity. A usual, there is lots to learn but the basic concepts
are not too difficult.
Latitude and Longitude represent the angle portion of a point in space
defined in polar coordinates. Recall that in 2 dimensional space a
point may be defined either by Cartesian or polar coordinates. A
Cartesian coordinate defines a location as the horizontal and v vertical
distance from some fixed point, the origin. Polar coordinates define
a point by the length and angle of a line segment from the origin to the
point. There is a Math-Topics page illustrating the relationship
between the two systems. Now, if we imagine a point on a flat
2-dimensional page defined by the two numbers and then we want to move the
point into 3-dimensional space by lifting up off the page, we need one
more number. For Cartesian coordinates, the third number will
be the height of the point above the page. For polar coordinates,
we'll lift the line segment up off of the page and measure the vertical
angle from the page up to the line.
Latitude and Longitude are the two polar coordinate angles.
If we imagine ourselves at the earth's center with our head pointing to
the North pole, the equator will be at 90 degrees from North - straight
out in from of us. . This imaginary line around the earth at
a 90 degree angle to the North pole is defined as 0 reference for
measuring Latitude, the North-South angular coordinate of a
point. Another imaginary line running north and south through the
poles and Greenwich England is the 0 degree reference for measuring
East-West angles, the Longitude. Latitudes range from 90 degrees
North to 90 degrees South with South angles treated as negative.
Longitudes range from 0 to 180 degrees East and West with West angles
treated a negative.
The actual math to calculate the distance between two points is
straightforward and derived in many places on the web, namely:
angular distance = arccos(Sin(lat1) * Sin(lat2) + Cos(lat1) *
Cos(lat2) * Cos(lon1-lon2)) and assuming that the angle is given in
degrees, distance = distance per degree*angular distance =
(2*Pi*radius/360)*angular distance. This is the spherical distance estimate produced by this program.
Flat Earth?
The above explanation considers the third parameter of the polar
coordinate defining a point, the length of the line segment, to be
constant, namely the radius of the earth. But in fact the earth is
not spherical. Our rotation has caused the earth to bulge slightly at
the equator and flatten at the poles. Sir Isaac Newton
in the 1600's calculated the radius at the poles to be 0.9967 of the
radius at the equator. The current value is about 0.9966 so
Sir isaac didn't do too badly. The difference of the two
circumferences (polar and equatorial) is about 83 miles, so spherical
coordinates for two points on on the equator but 180 degrees apart should
produce the maximum error, about 40 miles. By the way,
these distance estimates are "great circle estimates" meaning
they lie on the path defined by the plane through the two points plus the
earth's center and the surface of the earth. The great circle
route is the shortest surface distance between the two points.
Counter-intuitively, if you are north of the equator and want to get to a
point directly east of your current location, don't head east - the
shortest way is to start out traveling northeast and arrive traveling
southeast!
Calculating distances taking into account the elliptical shape of the
earth is quite complex. There are approximations that are at least close
to the true distance as those that assume a spherical earth.
The one used here is from http://www.codeguru.com/Cpp/Cpp/algorithms/general/article.php/c5115/
Running/Exploring the Program
Suggestions for Further Explorations
Most accurate calculation of surface distance
reportedly requires numeric integration of over the path between the
points. I assume that these are spherical trig estimates with the
radius adjusted for the "flatness" at the current
location. Might be interesting to try.
| Original Date: November 14, 2004 |
Modified: September 08, 2006
|
|