4

I am storing my Lat and Long values in the GEOMETRY type within MySql. Unfortunately it seems to be rounding to 4 decimal places, which according to this Wikipedia Article isn't very accurate. I want to use the Geospatial functions in mySql, but it seems to be lacking the precision I need. Any ideas what I can do? Can I increase the precision, or am I forced to store it as a double/float instead? If I want to use any of the other functionality in the GIS portion of mySql, will these values also be rounded (even if I store in seperate fields as another datatype)?

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
George Johnston
  • 31,652
  • 27
  • 127
  • 172
  • This *might* get a more useful response over at http://gis.stackexchange.com/ – Rowland Shaw May 06 '11 at 16:06
  • The reason might be the display precision loss of Navicat (Maybe due to setting or old version?). I have met the exactly same issue while processing multipolygons. And it turned out that it actually store more than 4 decimal places in the db. – user10253771 Dec 16 '21 at 10:34

2 Answers2

2

According to Alexey Botchkov:

...we use DOUBLE to store spatial coordinates which means 15 digit precision.

Source: http://bugs.mysql.com/bug.php?id=34075 (at the bottom).

So GEOMETRY types are already stored as doubles, no need to do that yourself.

Johan
  • 74,508
  • 24
  • 191
  • 319
  • But Actually We can store 14 digit in the database without any problem. Its just rounding off the 15th digit. As per my use case, I have to store Polygon shapes. In some cases, Vertex(lattitude, longitude) of the Polygon goes 15 to 20 digit precision. Is there any way to store these extra digit precision ? – ArunRaj Mar 07 '14 at 12:13
-1

Have a look at: What datatype to use when storing latitude and longitude data in SQL databases?

Decimal(9,6) would do and it provides an accuracy/error of about 1m.

Community
  • 1
  • 1
Rez.Net
  • 1,354
  • 2
  • 19
  • 28