Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

i need to find the distance between two gps location, So i think to do this:

  • lat1(seconds)-lat2(seconds)=lat * 30.7151 == distance latitude in meters =Latm

  • long1(seconds)-long2(seconds)=long *30.9221=== distance longitude in meters=Longm

for overall distance between them = sqr(Latm^2+Longm^2). note: the nodes are in range of 30 meters so i need to deal with seconds cause it is small scale.

share|improve this question

marked as duplicate by whuber Apr 19 '13 at 12:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

It would help if you can add which software or programming language you are using to achieve this. – Dipto Apr 19 '13 at 7:55
i use TinyOs programming for sensor nodes – Hanaa Apr 19 '13 at 8:19

Euclidean distances don't make much sense when calculated from lat/long. Haversine formula is used to calculate distance between lat/long on the surface of the earth surface. If the distance between the two places in question is large please consider using Haversine formula. Some detail and a calculator for Haversine formula can be found at:

If the places in question are not far apart, then you can convert the lat/long to UTM and then use the normal formula for Euclidean Distance:

share|improve this answer
in this link, i didn't know what this function ""atan2"" – Hanaa Apr 19 '13 at 8:23
atan2 is a function which is provided in most programming languages to calculate the arc-tangent between the 2 points; i.e the angle between 2 points. atan2 is special in the sense that it takes into account the signs of the inputs. I do not know whether the atan2 function is provided in TinyOS. If not atan2 can be implemented using normal arctangent function. Details about what the arctangent function is and how it can be implemented using atan can be found in the wikipedia page: . – Dipto Apr 19 '13 at 8:36
However, before implementing the atan2 function yourself, I would request you to check the API of TinyOS to see whether atan2 is supported. Generally this function is found in the math library of programming languages. – Dipto Apr 19 '13 at 8:39
o, i will check that. if i want to follow this equation <b> =ACOS(SIN(lat1)*SIN(lat2)+COS(lat1)*COS(lat2)*COS(lon2-lon1))*6371 </b> then the (lat,lon) in radian, but also when i use cos or cosd cos for degree cosd for radian i am confused if i use long and lat in radian then use the (cos and sin) in radian or degree ? – Hanaa Apr 19 '13 at 8:45
Generally one should use radians for calculations related to angles. You can use the normal cos and sin functions as long as you are using radians. – Dipto Apr 19 '13 at 8:50

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