Longitude and latitude coordinates are stored with 15 decimal digits right of the decimal points.
You can pack both the latitude and longitude values in a single 32-bit integer with a resolution of at worst ~2.4 meters/pixel (at the equator) if you use a recursive tiling system. Using two bits per level, you can store 16 levels in 32 bits.
Accuracy versus decimal places at the equator
decimal degrees distance
places
-------------------------------
0 1.0 111 km
1 0.1 11.1 km
2 0.01 1.11 km
3 0.001 111 m
4 0.0001 11.1 m
5 0.00001 1.11 m
6 0.000001 0.111 m
7 0.0000001 1.11 cm
8 0.00000001 1.11 mm
ref : https://en.wikipedia.org/wiki/Decimal_degrees#Precision
+----------------+-------------+
| Decimals | Precision |
+----------------+-------------+
| 5 | 1m |
| 4 | 11m |
| 3 | 111m |
+----------------+-------------+
If you want 50ft (15m) precision go for 4 digits.
So decimal(9,6)
I design databases and have been studying this question for a while. We use an off-the shelf application with an Oracle backend where the data fields were defined to allow 17 decimal places. Ridiculous! That's in the thousandths of an inch. No GPS instrument in the world is that accurate. So let's put aside 17 decimal places and deal with practical. The Government guarantees their system is good to "a "worst case" pseudorange accuracy of 7.8 meters at a 95% confidence level" but then goes on to say actual FAA (using their high quality instruments) has shown GPS readings to usually be good to within a meter.
So you have to ask yourself two questions: 1) What is the source of your values? 2) What will the data be used for?
Cell phones are not particularly accurate, and Google/MapQuest readings are probably only good to 4 or 5 decimals. A high quality GPS instrument might get you 6 (within the United States). But capturing more than that is a waste of typing and storage space. Furthermore, if any searches are done on the values, it's nice for a user to know that 6 would be the most he/she should look for (obviously any search value entered should first be rounded to the same accuracy as the data value being searched).
Furthermore, if all you're going to do is view a location in Google Maps or put it in a GPS to get there, four or five is plenty.
I have to laugh at people around here entering all those digits. And where exactly are they taking that measurement? Front door knob? Mailbox out front? Center of building? Top of cell tower? AND... is everyone consistently taking it at the same place?
As a good database design, I would accept values from a user for maybe a few more than five decimal digits, then round and capture only five for consistency [maybe six if your instruments are good and your end use warrants it].
The distance between each degree of latitude varies because of the shape of the earth and distance between each degree of longitude gets smaller as you get closer to the poles. So let's talk about the equator, where the distance between each degree is 110.574km for latitude and 111.320km for longitude.
50ft is 0.01524km, so:
You need four digits of scale, enough to go down to ten-thousandths of a degree, with a total of seven digits of precision.
DECIMAL(7,4)
should be plenty for your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With