Created : Nov 2008
** Comment on this article **
** Comment on this article **
** Comment on this article **
GPS co-ordinate Resolutions
Here is a typical GPS co-ordinate :
san francisco,ca (lat : 37.775196, long : -122.419204)
Ever wonder how much distance each digit represents? Here is a breakdown.
Note: The points compared are diagonal (bot LAT and LON are incremented). And these distances vary depending on the location.
| Coordinate | Position | distance (meters) | distance (km) | distance (miles) | distance (feet) |
|---|---|---|---|---|---|
| Reference Co-ord 37.0, 122.0 |
|||||
| 47.0, 132.0 | 10s | 1,382,074 | 1,382 | 859 | 4,534,363 |
| 38.0, 123.0 | 1 | 141,847 | 141 | 88 | 465,377 |
| 37.1, 122.1 | 1st decimal | 14,218 | 14 | 8.8 | 46,647 |
| 37.01, 122.01 | 2nd decimal | 1,422 | 1.4 | 0.8 | 4,665 |
| 37.001, 122.001 | 3rd decimal | 142 | .1 | 0.09 | 466 |
| 37.0001, 122.0001 | 4th decimal | 14 | 0 | 0 | 46 |
| 37.00001, 122.00001 | 5th decimal | 1 | 0 | 0 | 3 |
| 37.000001, 122.000001 | 6th decimal | 0 | 0 | 0 | 0 |
So 6 decimal resolution should serve us pretty well.
Plug the numbers in the calculator here : http://www.gpsvisualizer.com/calculators.
Here is the RUBY script I use for calculating 'great circle distance':
geopoint.rb:
class Geopoint
attr_accessor :lat, :lon
def initialize(alat, alon)
@lat = alat.to_f
@lon = alon.to_f
end
# calculates the distance in meters
def distance(other)
lat1 = @lat
lon1 = @lon
lat2 = other.lat
lon2 = other.lon
return -1 if (lat2 == nil || lon2 == nil)
## following is standard
r = 6367000 # earth's mean radius in m
lat1 = lat1 * Math::PI / 180
lat2 = lat2 * Math::PI / 180
lon1 = lon1 * Math::PI / 180
lon2 = lon2 * Math::PI / 180
re = 6378137 # equatorial radius (meters)
rp = 6356752 # polar radius
r45 = re * Math.sqrt( (1 + ( (rp*rp-re*re)/(re*re) ) * (Math.sin(45)*Math.sin(45)) ) ) # from http://www.newton.dep.anl.gov/askasci/gen99/gen99915.htm
deltaLat = lat2 - lat1
deltaLon = lon2 - lon1
a = Math.sin(deltaLat/2) * Math.sin(deltaLat/2) + Math.cos(lat1) * Math.cos(lat2) * Math.sin(deltaLon/2) * Math.sin(deltaLon /2)
c = 2 * Math.atan(Math.sqrt(a) / Math.sqrt(1-a))
dist = r * c
return dist.round
end
end
meter.rb:
# Distance class, created using meters
#class Float < Numeric
class Numeric
def to_km
return self/1000
end
def to_mile
return self * 0.000621371192
end
def to_feet
return self * 3.2808399
end
def pretty_print
return (self*10).truncate / 10
end
end
gps-resolution.rb:
require File.dirname(__FILE__) + "/geopoint"
require File.dirname(__FILE__) + "/meter"
## also check : http://www.gpsvisualizer.com/calculators
ref = Geopoint.new(37.0, 122.0)
points = Array [
Geopoint.new(47.0, 132.0),
Geopoint.new(38.0, 123.0),
Geopoint.new(37.1, 122.1),
Geopoint.new(37.01, 122.01),
Geopoint.new(37.001, 122.001),
Geopoint.new(37.0001, 122.0001),
Geopoint.new(37.00001, 122.00001),
Geopoint.new(37.000001, 122.000001)
]
points.each do |p|
d = ref.distance(p)
puts "#{ref.inspect} #{p.inspect} = #{d} meters, #{d.to_km} km, #{d.to_mile} miles, #{d.to_feet} feet"
end
Output:
#<Geopoint:0x25850 @lon=122.0, @lat=37.0> #<Geopoint:0x2501c @lon=132.0, @lat=47.0> = 1382074 meters, 1382 km, 858.780968812208 miles, 4534363.5239526 feet #<Geopoint:0x25850 @lon=122.0, @lat=37.0> #<Geopoint:0x25008 @lon=123.0, @lat=38.0> = 141847 meters, 141 km, 88.139639471624 miles, 465377.2972953 feet #<Geopoint:0x25850 @lon=122.0, @lat=37.0> #<Geopoint:0x24ff4 @lon=122.1, @lat=37.1> = 14218 meters, 14 km, 8.834655607856 miles, 46646.9816982 feet #<Geopoint:0x25850 @lon=122.0, @lat=37.0> #<Geopoint:0x24fe0 @lon=122.01, @lat=37.01> = 1422 meters, 1 km, 0.883589835024 miles, 4665.3543378 feet #<Geopoint:0x25850 @lon=122.0, @lat=37.0> #<Geopoint:0x24fcc @lon=122.001, @lat=37.001> = 142 meters, 0 km, 0.088234709264 miles, 465.8792658 feet #<Geopoint:0x25850 @lon=122.0, @lat=37.0> #<Geopoint:0x24fb8 @lon=122.0001, @lat=37.0001> = 14 meters, 0 km, 0.008699196688 miles, 45.9317586 feet #<Geopoint:0x25850 @lon=122.0, @lat=37.0> #<Geopoint:0x24fa4 @lon=122.00001, @lat=37.00001> = 1 meters, 0 km, 0.000621371192 miles, 3.2808399 feet #<Geopoint:0x25850 @lon=122.0, @lat=37.0> #<Geopoint:0x24f90 @lon=122.000001, @lat=37.000001> = 0 meters, 0 km, 0.0 miles, 0.0 feet
** Comment on this article **