# Geo Location

## [How accurately should I store latitude and longitude?](https://stackoverflow.com/questions/7167604/how-accurately-should-i-store-latitude-and-longitude)

```
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>

## [What is the ideal data type to use when storing latitude / longitude in a MySQL database?](https://stackoverflow.com/questions/159255/what-is-the-ideal-data-type-to-use-when-storing-latitude-longitude-in-a-mysql)

In SQL database, Latitude and Longitude data types should use **DECIMAL** instead of **FLOAT.**

E.g. DECIMAL(9,6) depending on the precision required

`###.######`

OR

**Use MySQL's spatial extensions with GIS.**

Another practical way is to use integer or number.

> We store **latitude/longitude X** **1,000,000** in our oracle database as **NUMBERS** to **avoid round off errors with doubles**.
>
> Given that latitude/longitude to the **6th decimal** **place** was **10 cm** accuracy that was all we needed. Many other databases also store lat/long to the 6th decimal place.

Thus an Int data type could also serve the purpose. Say `168.123456 * 1 000 000 = 168 123 456` is still much less than the signed integer limit which is around 2 billion (2 \* 10^9).
