I am trying to write a function that calculates the GPS (decimal) coordinates of a point that is far of a given distance from a given point. Let say that we start from point 1 (The stripe of Dublin) and we want to move 25km east.

This is what I have written:

import math 
# Coordinates of "The Spire" (Dublin)
bearing=90 #degree from North
distance=25000 # distance in meter
alpha = math.radians(bearing)
radius=6371000 # radius of Earth (in meter)
gamma = distance / radius
lat1_r= math.radians(lat1_dg)
lon1_r= math.radians(lon1_dg)
Δlat_r = gamma * math.cos(alpha)
lat2_r = lat1_r + Δlat_r
Δlon_r = gamma * math.sin(alpha)/math.cos(lat1_r)
lon2_r = lon1_r + Δlon_r

This outputs the following, which is close to the correct answer

53.349720000000005 -5.883634969206713

but if I calculate the distance between point 1 and point 2 with this tool, I get 25.008 meters...why?


Check your units in the Andrew Hedges Haversine tool - it gives me 25.008 km ! (or 15.543 miles)

(also by just looking at your coords, you can see it should be 10s of km and not metres - a degree is usually somewhere in the 50-100km range - this is a very rough approximation but gives you a clue)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.