This is my code for adding GPS for photos from Google Takeout json file:
if __name__ == '__main__':
from sys import argv
opt = OptionParser()
opt.add_option('-l', '--location')
# not sure what this timezone offset is because before
# day light saving it was set to 0 and was working maybe it time shift
opt.add_option('-t', '--timezone')
(options, args) = opt.parse_args()
if options.location is None or len(args) != 1:
print "usage %s [--timezone <hours shift>] --location [History JSON File] <IMAGE FILE>" % argv[0]
else:
gps_list = json.loads(open(options.location).read())
date = parse_date(get_date_taken(args[0]))
if options.timezone is not None:
loc = get_gps(gps_list, date, -float(options.timezone))
else:
loc = get_gps(gps_list, date)
found = datetime.fromtimestamp(
int(loc['timestampMs']) / 1000.0
)
print "%s == %s" % (date, found)
# this conversion seems to be correct (get it from other SO question)
print loc
print "lat: %s" % str(int(loc['latitudeE7']) / 1e7)
print "long: %s" % str(int(loc['longitudeE7']) / 1e7)
call([
'exiftool',
'-m',
'-GPSLatitude=%s' % str(int(loc['latitudeE7']) / 1e7),
'-GPSLongitude=%s' % str(int(loc['longitudeE7']) / 1e7),
args[0]
])
I've checked the output for single photo at this GPS checker and the location is about right, but when I've added GPS to the picture and uploaded it to pic2map.com it's way off (few km in other direction).
DO you know any other GPS location checker maybe pic2map is not correct and show wrong position. Or is exif tool accept different data. If so how can I correct the exif tool data to get correct GPS location of photos. (I mainly want to have GPS for flickr so it's added to GPS location services to have correct GPS to search for).
EDIT:
Takeout json look like this:
{
"locations" : [ {
"timestampMs" : "1406974281661",
"latitudeE7" : 511162000,
"longitudeE7" : 208802232,
"accuracy" : 19
}, {
"timestampMs" : "1406974327231",
"latitudeE7" : 511161756,
"longitudeE7" : 208801345,
"accuracy" : 7
}, {
"timestampMs" : "1406974373278",
"latitudeE7" : 511161741,
"longitudeE7" : 208801377,
"accuracy" : 7,
"activity" : [ {
"timestampMs" : "1406974371946",
"activity" : [ {
"type" : "IN_VEHICLE",
"confidence" : 63
}, {
"type" : "STILL",
"confidence" : 37
} ]
} ]
}
...
}, {
"timestampMs" : "1556810257251",
"latitudeE7" : 511051671,
"longitudeE7" : 207460199,
"accuracy" : 9,
"velocity" : 0,
"altitude" : 323,
"verticalAccuracy" : 33
} ]
}