1

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)
lat1_dg=53.34972
lon1_dg=-6.26028
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
lat2_dg=(math.degrees(lat2_r))
lon2_dg=(math.degrees(lon2_r))
print(lat2_dg,lon2_dg)

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?

2

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)

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.