Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

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

3 Answers 3

up vote 34 down vote accepted

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).

share|improve this answer
    
I suppose this could work; what would the range be - within 10 degrees of the poles? –  Thomas O Oct 27 '10 at 11:25
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
17  
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
2  
@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
2  
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
show 3 more comments

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
 R=6378137

 //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
share|improve this answer
3  
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 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
show 2 more comments

I find that Aviation Formulary, http://williams.best.vwh.net/avform.htm, is great for these types of formulas and algorithms. For your problem, check out the "lat/lon given radial and distance": http://williams.best.vwh.net/avform.htm#LL.

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

share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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