I'm building an indoor wifi-based tracking system that can calculate the position of a device in meters relative to the sensors distributed throughout the building. So far I've gotten to the point where I have the ability to sense the device and trilaterate its position on an arbitrary x-y grid (in meters) where the sensor locations are known, but now I need to output that to Google Maps for display. I'm stuck trying to figure out how to convert this system to latitude and longitude, and be accurate to within a meter. I've seen some estimations people have used for such applications, but they're plotting on a much larger scale so an error of 10m or so is acceptable. In my case, 10m would make the data completely unusable.

Is there an easy way to make this conversion? I can find the lat/lon of the sensors, but I don't know where to go from there. My equations are based on a point-coordinate system, so I can't use a vector system or other method without redesigning everything.

  • 1
    If the accuracy goal is related to display on Google Maps, then Google's accuracy may compound your problem (see this blog post, for example, which finds a ~10m error).
    – Erica
    Jul 22, 2014 at 12:49
  • Hm very good point... unfortunately I don't have time to redesign the system I'm using so I'll have to rely on it for now. I was already not happy about using Google Maps (note that my equations are based on x-y coordinates, that's what I was planning on using for display) but I've been forced to go that direction for the moment.
    – thanby
    Jul 22, 2014 at 13:24
  • 2
    Actually thinking about it more, you may be OK, since you're going to be measuring distances from a position derived from Google Maps. The point would be ~10m inaccurate with respect to real-world location, but should be acceptably accurate with respect to photo-of-world location.
    – Erica
    Jul 22, 2014 at 13:46

3 Answers 3


To a high relative accuracy, in this application--where the region to be mapped will not extend more than a few hundred meters and it is not near either pole--you can treat lat-lon as a Cartesian coordinate system that uses two different linear units of measure.

Each degree of latitude will be approximately 111300 meters (and a more accurate value, which may differ from this by up to a few hundred meters, can be found once and for all by consulting tables or through a preliminary calculation). Each degree of longitude will be approximately 111300 * cos(latitude) meters (with the same possibility of making it a little more accurate with a little more preliminary work). For the latitude in the equation use the latitude of the middle of the building. The errors will be much smaller than one meter.

For example, suppose you locate an object 10 meters west and 20 meters north of a sensor at (lat, lon) = (45.000100, 6.500000) and the building's center is at latitude 45 degrees. Since cos(45) = 0.7071068, each degree of longitude is worth 111300 * 0.7071068 = 78701 meters. Therefore the object is displaced 10/78701 = 0.0001271 degrees west (which is the negative direction) and 20/111300 = 0.0001797 degrees north. This would locate it at (lat, lon) = (45.000100, 6.500000) + (0.000180, -0.000127) = (45.000280, 6.499873).

Assuming the sensor locations are perfectly accurate, note that even a 5% error in these particular calculations would still place the final coordinates within 5%*20 = 1 meter of their correct locations. That's why there's no need to be finicky about accuracy in the conversion from meters to degrees: one part in a thousand would be more than good enough for any building.

(For advice on precision in these coordinates please see Measuring accuracy of latitude and longitude?.)

  • 1
    Hm your reasoning seems pretty solid there. I was afraid the error would be larger. I just gave it a shot and things seem pretty accurate so far.
    – thanby
    Jul 23, 2014 at 13:47

How are you obtaining your lat/longs out of curiosity? Without access to a DGPS you will be hard pressed to get sub metre accuracy anyway.

This 2 point Coordinate Transformations (Basic) spreadsheet is quite useful. Try to use control points at the outer extremities of your site as the further from these points you are the less accurate the transformation. There are also many other useful equations etc listed on that website. Higher accuracy can be obtained by other transformation methods such as 'helmert' or 'affine'. In a nutshell the more points in differing coordinate systems you can provide, the more accurate the transformation.

  • The points are from overlaying a building map on Google Maps, which as @Erica pointed out, is questionable in its accuracy (which means in the long run I'm going to have to rethink this, but for now I don't have a choice). Thanks for the link, I'll try to implement that and follow up with you about it!
    – thanby
    Jul 22, 2014 at 13:22
  • Good luck. I forgot to mention, the points in that spreadsheet should be in metres. I suggest converting the lat/longs into whatever UTM zone you are in first. There are numerous online or offline conversion tools for this.
    – elmato
    Jul 22, 2014 at 14:21

http://www.whoi.edu/marine/ndsf/cgi-bin/NDSFutility.cgi?form=0&from=XY&to=LatLon this site has everything you need THANBY


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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