Google Takeout Geolocation – Handling Out of Range Latitude and Longitude Values

convertgeolocationinvalid-datalatitude longitude

I've exported my geolocation history data as a JSON from Google Takeout and the latitude/longitude values are out of normal range sometimes. It seems to happen for some locations only, while others are normal and correct.

Here's a small extract of three dates with the invalid lat/long values and where I actually was at the time, is there some common transformation I need to use here that fixes this:

Date        lat         long        Location
13/01/2014  423.3738877 106.6510714 Jakarta, Indonesia (-6.23,106.76)
28/10/2015  397.6754516 115.7765074 Perth, Western Australia (-31.91,115.88)
8/08/2017   409.237868  372.8135318 Miranda, Brazil (-20.13, -56.88)

In the raw JSON file, the above three data points look like this (in the same order as listed above):

{
  "locations" : [ {
    "timestampMs" : "1389633689564",
    "latitudeE7" : 4233738877,
    "longitudeE7" : 1066510714,
    "accuracy" : 20
  }, {
    "timestampMs" : "1446040136103",
    "latitudeE7" : 3974349226,
    "longitudeE7" : 1157765074,
    "accuracy" : 1212
  }, {
    "timestampMs" : "1502203327757",
    "latitudeE7" : 4094251339,
    "longitudeE7" : 3728135318,
    "accuracy" : 16
  } ]
}

Best Answer

They seem to have an integer overflow error in preparing the data for the takeout (downloading the kml directly from google maps for a specific day works correct).

If the number is greater than 1800000000 (for latitude, also comparing to 900000000 would work) you need to subtract 2^32 (=4294967296) and you get the correct latitudeE7 or longitudeE7.

Your first example would be:

latitudeE7 = 4233738877 - 4294967296 = -61228419 (= 6.12 South)
longitudeE7 = 1066510714 (= 106.7 East, no conversion here)

Related Question