Just found and tested a GPS distance calculator. It returns the distance in meters. The arguments are two dictionaries that each contain a 'lat' key with value decimal degree and a 'long' key with value decimal degree. The code:
import math
RADIUS = 6378700 #radius of earth in meters
#test gps values (don't need these)
#the distance between them should be just under 1600m
gps1 = {'lat':34.150350, 'long':-118.427360}
gps2 = {'lat':34.150367, 'long':-118.410729}
def gpsDistance (gpsA, gpsB):
"""
Computes the distance between two lat/long points.
The formula uses radians, so degrees must be
converted to radians first. RADIUS is the
radius of the surface of the earth in the units
we want.
FORMULA:
r * arccos[sin(lat1/57.2958) * sin(lat2/57.2958) +
cos(lat1/57.2958) * cos(lat2/57.2958) * cos(lon2/57.2958 -lon1/57.2958)]
"""
radianScale = math.pi / 180.0
lat1rad = gpsA['lat']*radianScale
lat2rad = gpsB['lat']*radianScale
lon1rad = gpsA['long']*radianScale
lon2rad = gpsB['long']*radianScale
part1 = math.sin(lat1rad) * math.sin(lat2rad)
part2 = math.cos(lat1rad) * math.cos(lat2rad) *\
math.cos(lon2rad-lon1rad)
return RADIUS * math.acos(part1 + part2)
