I'm looking for an algorithm which when given a latitude and longitude pair and a vector translation in meters in Cartesian coordinates (x,y) would give me a new coordinate. Sort of like a reverse Haversine. I could also work with a distance and a heading transformation, but this would probably be slower and not as accurate. Ideally, the algorithm should be fast as I'm working on an embedded system. Accuracy is not critical, within 10 meters would be good.

  • So you'd be fine modeling the earth as a sphere? – underdark Oct 26 '10 at 22:54
  • 1
    Yeah, that would be fine as I'm expecting <1km offsets. – Thomas O Oct 26 '10 at 22:58

If your displacements aren't too great (less than a few kilometers) and you're not right at the poles, use the quick and dirty estimate that 111,111 meters (111.111 km) in the y direction is 1 degree (of latitude) and 111,111 * cos(latitude) meters in the x direction is 1 degree (of longitude).

| improve this answer | |
  • 3
    @Thomas: Actually, you can be very close to the poles. I checked against a UTM calculation using equal x- and y-displacements of 1400 m (so the total displacement is 2 km). The results are good to 8.6 meters or better. The worst latitude (for this direction and amount of displacement) is 81 degrees: the approximation actually gets more accurate as you move north and its error stays below 10 meters until you get beyond 89.6 degrees! – whuber Oct 27 '10 at 21:36
  • 64
    Incidentally, these magic numbers of 111,111 are easy to remember by knowing some history: the French originally defined the meter so that 10^7 meters would be the distance along the Paris meridian from the equator to the north pole. Thus, 10^7 / 90 = 111,111.1 meters equals one degree of latitude to within the capabilities of French surveyors two centuries ago. – whuber Oct 27 '10 at 21:38
  • 4
    So with the formula if I wanted to move +100m in the y direction from say 10.0 N, 10.0 E, would I just add 100 / 111111? If moving in the x direction +100m, would it be 100÷(111,111×(cos 10))? Just making sure I've got this right. – Thomas O Oct 27 '10 at 21:47
  • 6
    @Thomas Yes, that's right. Note how the second formula expands the apparent x-displacement (by virtue of dividing by a number less than 1) as it should, because a degree of longitude gets smaller as you move towards the poles from the equator. The only potential hitch is to make sure you and your software platform agree on what "cos" means: it had better interpret cos(10) as the cosine of 10 degrees, not 10 radians! (If not, 10 degrees = 10 * pi / 180 radians illustrates the simple conversion.) At this point, the code offered by @haakon_d should make complete sense to you. – whuber Oct 27 '10 at 21:54
  • 8
    Somebody attempted to edit this answer to replace "meters" by "km." They probably were reading the comma "," in the European sense of a decimal point. I follow the American convention (which I believe is the convention of international publications, too) of using a comma to separate long digit strings into groups of three and a decimal point "." instead of the comma. (This usage is clearly shown in previous comments.) To avoid any ambiguity I have edited the answer to show clearly what the comma and point mean. – whuber Feb 11 '13 at 16:20

As Liedman says in his answer Williams’s aviation formulas are an invaluable source, and to keep the accuracy within 10 meters for displacements up to 1 km you’ll probably need to use the more complex of these.

But if you’re willing to accept errors above 10m for points offset more than approx 200m you may use a simplified flat earth calculation. I think the errors still will be less than 50m for offsets up to 1km.

 //Position, decimal degrees
 lat = 51.0
 lon = 0.0

 //Earth’s radius, sphere

 //offsets in meters
 dn = 100
 de = 100

 //Coordinate offsets in radians
 dLat = dn/R
 dLon = de/(R*Cos(Pi*lat/180))

 //OffsetPosition, decimal degrees
 latO = lat + dLat * 180/Pi
 lonO = lon + dLon * 180/Pi 

This should return:

 latO = 51,00089832
 lonO = 0,001427437
| improve this answer | |
  • 9
    I just want to point out that this is identical to the answer I provided except you have replaced my value of 111,111 meters per degree by 111,319.5. Your value is slightly better at high latitudes but slightly worse in the lower latitudes (from 0 to about 40 degrees). Either value meets the stated requirements of accuracy. – whuber Oct 27 '10 at 21:42
  • 1
    +1 for providing code. Note that it's more accurate than you suspect (the error is typically less than 5 m over 2000 m). – whuber Oct 27 '10 at 21:55
  • 1
    I wondered if I should add a remark in my answer that this is an identical solution to yours except for the value of R, but left it out due to brevity. When it comes to precision you’re right as long as you don’t add any rotational errors to the system. Using offsets measured in a local projected coordinate system the rotational errors may grow quite large. – haakon_d Oct 28 '10 at 8:33
  • 1
    That's an excellent point: we have implicitly assumed the x-displacement is at least close to true east-west and the y-displacement is close to north-south. If not, they have to be converted into equivalent E-W and N-S displacements (not just "eastings" and "northings") before computing their lat-lon equivalents. – whuber Nov 2 '10 at 21:35
  • The d distance parameter of the Aviation Formulary equations is in radians, e.g. (distance/radius-of-earth). – user1089933 Nov 15 '12 at 21:10

I find that Aviation Formulary, here is great for these types of formulas and algorithms. For your problem, check out the "lat/long given radial and distance":here

Note that this algorithm might be a bit too complex for your use, if you want to keep use of trigonometry functions low, etc.

| improve this answer | |
  • Thanks for this - looks ideal. Though I can't figure out if the distance is in meters or some other measurement. – Thomas O Oct 27 '10 at 11:25

It might make sense to project the point first. You could make something like this pseudo-code:

falt_coordinate = latlon_to_utm(original_koordinate)
new_flat_coordinate = flat_coordinate + (x,y)
result_coordinate = utm_to_latlon(new_flat_coordinate)

where (x,y) is the desired offset.

You don't need to use utm, any flat coordinate system, that makes sense in your area will do.

What software are you working with?

| improve this answer | |

I created a simple custom map on Google Maps that illustrates the estimation algorithm mentioned by the accepted answer (1/111111 == one meter). Feel free to see and play with it here:


enter image description here

| improve this answer | |

Vincenty's direct formula should do the job.

| improve this answer | |
  • 2
    Welcome to GIS SE! As a new user please take the tour. A good answer should be self-contained, and include all the steps and details required. Please edit your answer to add explanation as to how to use your suggestion, and why. – Midavalo Jul 27 at 1:54

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.