351

How many digits can latitude and longitude have, before the decimal, and after the decimal?

Here is an example I am getting from the location sent by a Windows Phone device:

Latitude=-63572375290155
Longitude=106744840359415

This is very long and is exceeding my table column size and causes errors.

Mayer Spitzer
  • 1,791
  • 12
  • 22
user2273259
  • 3,519
  • 2
  • 11
  • 3
  • 8
    Are you sure these are lat/long ? Max/Min of them are lat +90 to -90 long +180 to -180, I would say there is a missing comma... saving it as float in the db would be enough, if it is formated correctly. But I think something goes wrong because your values can't be true – Xavjer Apr 12 '13 at 07:12
  • 2
    You are using some API to get these values. Presumably, the API comes with documentation. What does the documentation say about the units? – NPE Apr 12 '13 at 07:32
  • 21
    I suspect that the numbers are actually -63.572375290155 and 106.744840359415, which is just off the coast of Antarctica. A latitude or longitude with seven decimal places is accurate to 5 feet. Any more than 8 decimal places is noise. – Gilbert Le Blanc Apr 12 '13 at 12:05
  • 1
    [See also](https://gis.stackexchange.com/questions/8650/measuring-accuracy-of-latitude-and-longitude) – Ross Rogers May 24 '18 at 20:45
  • 3
    I'm voting to close this question as off-topic because it's not about software development. – Jim G. Apr 08 '19 at 19:13
  • Google Maps actually uses signed values to represent the position: Latitude : max/min 90.0000000 to -90.0000000 Longitude : max/min 180.0000000 to -180.0000000 So if you want to work with Coordinates in your projects you would need DECIMAL(10,7) ie. for SQL. – Dimitri de Jesus Oct 19 '20 at 03:22

7 Answers7

700

If the latitude coordinate is reported as -6.3572375290155 or -63.572375290155 in decimal degrees then you could round-off and store up to 6 decimal places for 10 cm (or 0.1 meters) precision.

Overview

The valid range of latitude in degrees is -90 and +90 for the southern and northern hemisphere respectively. Longitude is in the range -180 and +180 specifying coordinates west and east of the Prime Meridian, respectively.

For reference, the Equator has a latitude of 0°, the North pole has a latitude of 90° north (written 90° N or +90°), and the South pole has a latitude of -90°.

The Prime Meridian has a longitude of 0° that goes through Greenwich, England. The International Date Line (IDL) roughly follows the 180° longitude. A longitude with a positive value falls in the eastern hemisphere and the negative value falls in the western hemisphere.

Decimal degrees precision

Six (6) decimal places precision in coordinates using decimal degrees notation is at a 10 cm (or 0.1 meters) resolution. Each .000001 difference in coordinate decimal degree is approximately 10 cm in length. For example, the imagery of Google Earth and Google Maps is typically at the 1-meter resolution, and some places have a higher resolution of 1 inch per pixel. One meter resolution can be represented using 5 decimal places so more than 6 decimal places are extraneous for that resolution. The distance between longitudes at the equator is the same as latitude, but the distance between longitudes reaches zero at the poles as the lines of meridian converge at that point.

For millimeter (mm) precision then represent lat/lon with 8 decimal places in decimal degrees format. Since most applications don't need that level of precision 6 decimal places is sufficient for most cases.

In the other direction, whole decimal degrees represent a distance of ~111 km (or 60 nautical miles) and a 0.1 decimal degree difference represents a ~11 km distance.

Here is a table of # decimal places difference in latitude with the delta degrees and the estimated distance in meters using 0,0 as the starting point.

Decimal places Decimal degrees Distance (meters)
1 0.10000000 11,057.43 11 km
2 0.01000000 1,105.74 1 km
3 0.00100000 110.57
4 0.00010000 11.06
5 0.00001000 1.11
6 0.00000100 0.11 11 cm
7 0.00000010 0.01 1 cm
8 0.00000001 0.001 1 mm

Degrees-minute-second (DMS) representation

For DMS notation 1 arc second = 1/60/60 degree = ~30 meter length and 0.1 arc sec delta is ~3 meters.

Example:

  • 0° 0' 0" W, 0° 0' 0" N0° 0' 0" W, 0° 0' 1" N ⟹ 30.715 meters
  • 0° 0' 0" W, 0° 0' 0" N0° 0' 0" W, 0° 0' 0.1" N ⟹ 3.0715 meters

1 arc minute = 1/60 degree = ~2000m (2km)


Update:

Here is an amusing comic strip about coordinate precision.

JasonM1
  • 16,774
  • 4
  • 25
  • 61
  • 2
    What about the Longtitude. How much decimal place precision is enough to hold it. – ArunRaj Mar 17 '14 at 09:27
  • 15
    6 decimal place difference (0.000001) in latitude is ~0.11 meters length and in longitude is ~0.11 meters at latitude near equator and near the poles delta in longitude is much smaller distance (4 decimal degrees becomes 20 cm). So on average 6 decimal places is sufficient for 10cm in resolution. – JasonM1 Mar 17 '14 at 14:02
  • 1
    Might I suggest using `0.1 m` where you are currently using `10 cm` (except when you say "approximately 10 cm"). Otherwise excellent answer. – Floris Apr 03 '15 at 12:06
  • 1
    More on lat/lng precision: http://mysql.rjweb.org/doc.php/latlng#representation_choices – Rick James Mar 04 '19 at 00:08
  • 2
    Google Maps actually uses signed values to represent the position: Latitude : max/min 90.0000000 to -90.0000000 Longitude : max/min 180.0000000 to -180.0000000 So if you want to work with Coordinates in your projects you would need DECIMAL(10,7) ie. for SQL. – Dimitri de Jesus Oct 19 '20 at 03:22
213

Google Maps actually uses signed values to represent the position:

  • Latitude : max/min 90.0000000 to -90.0000000

  • Longitude : max/min 180.0000000 to -180.0000000

So if you want to work with Coordinates in your projects you would need DECIMAL(10,7) ie. for SQL.

Dimitri de Jesus
  • 775
  • 7
  • 12
Layke
  • 45,997
  • 10
  • 79
  • 109
31

Valid longitudes are from -180 to 180 degrees.

Latitudes are supposed to be from -90 degrees to 90 degrees, but areas very near to the poles are not indexable.

So exact limits, as specified by EPSG:900913 / EPSG:3785 / OSGEO:41001 are the following:

  • Valid longitudes are from -180 to 180 degrees.
  • Valid latitudes are from -85.05112878 to 85.05112878 degrees.
Mikhail Vasin
  • 1,843
  • 1
  • 19
  • 27
  • 12
    The limits mentioned in this answer are for a specific MAP PROJECTION. This answer is not a valid answer to the question and misleading. A completely different issue. – bugmenot123 May 02 '18 at 15:03
  • Do you know why the valid latitudes are from -85 to 85? I have been looking all over to find out the reason behind it. I'd love to know the reason behind it. – Ludvig W Jun 05 '18 at 06:58
  • 2
    @Lurr Perhaps because you don't want to end at the North and South Pole. If the earth is a bit flatten at the poles, then it makes sens to taper off and flattens around 85 before it reaches the 90th degree – Nditah Aug 13 '18 at 16:24
  • I don't understand that. Could you go more into detail why a latitude of 89 would be an issue? Does this mean that with the given protection since areas around the poles cannot be specified? – Martin Thoma Aug 11 '20 at 08:42
24

Latitude maximum in total is: 9 (12.3456789), longitude 10 (123.4567890), they both have maximum 7 decimals chars (At least is what i can find in Google Maps),

For example, both columns in Rails and Postgresql looks something like this:

t.decimal :latitude, precision: 9, scale: 7
t.decimal :longitude, precision: 10, scale: 7
Bengala
  • 865
  • 8
  • 15
  • 1
    max 7 decimal chars is wrong!! 8 is correct (rare, but possible)! see https://en.wikipedia.org/wiki/Decimal_degrees – jasie Aug 11 '20 at 07:14
  • Yeah maybe you are right. Don't know if many web services accept the 8 decimal chars, but they should now. – Bengala Sep 09 '20 at 19:09
8

The ideal datatype for storing Lat Long values in SQL Server is decimal(9,6)

As others have said, this is at approximately 10cm precision, whilst only using 5 bytes of storage.

e.g. CAST(123.456789 as decimal(9,6)) as [LatOrLong]

ukgav
  • 91
  • 1
  • 3
4

I am aware there are already several answers, but I added this, as this adds substantial information about the decimal places and hence the asked maximum length.

The length of latitude and langitude depend on precision. The absolute maximum length for each is:

  • Latitude: 12 characters (example: -90.00000001)
  • Longitude: 13 characters (example: -180.00000001)

For both holds: a maximum of 8 decial places is possible (though not commonly used).

Explanation for the dependency on precision:

enter image description here

See the full table at Decimal degrees article on Wikipedia

jasie
  • 1,453
  • 4
  • 23
  • 32
0

Please check the UTM coordinate system https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system.

These values must be in meters for a specific map projection. For example, the peak of Mount Assiniboine (at 50°52′10″N 115°39′03″W) in UTM Zone 11 is represented by 11U 594934.108296 5636174.091274 where (594934.108296, 5636174.091274) are in meters.

Kishantha
  • 11
  • 1
  • Good call. If your Toronto coordinates (43.6, -79.4) looks like: 630001.79, 4833599.08 then the data is in UTM https://www.latlong.net/lat-long-utm.html – jonincanada Aug 16 '20 at 14:44