bibinwilson
bibinwilson

Reputation: 358

How to add GPS latitude and longitude using Exiftool in mac (how to edit meta data in jpeg)

I have a bunch jpeg image that is obtained from FLIR camera. Along with that images I collected the GPS coordinates also. Now I'm trying to take the GPS latitude and longitude to the metadata of the image.

I wrote a program in R programming language to find the GPS location of each image with respect to the time(when ever the GPS location time and the camera time matches, I took that coordinates).

ie, for a particular image, I have GPSLatitude <- 19.33423 and GPSLongitude <- 72.090834

But now I need to add those exact GPS location to the image.

I tried to do that with Exiftool. I'm using Mac osX sierra. In that I installed exiftool. But now I don't know the how to update GPS data using that.

Can anyone help me. If possible let me know the method to update the data directly from the R programming language itself

Thanks

Upvotes: 3

Views: 14518

Answers (6)

Zax71
Zax71

Reputation: 29

Google Maps outputs locations in the format 0°1'2.3"N 4°5'6.7"W so it's quite a common format to use. To write this to an image in ExifTool you use the following:

exiftool -EXIF:GPSLatitude="0 1 2.3" -EXIF:GPSLongitude="4 5 6.7" -GPSLatitudeRef="North" -GPSLongitudeRef="West" 

With the latitude and longitude being that of the locations but replacing °, " and ' with spaces. Then the references being the N for North and W for West as EXIF does not support signed values for GPS location

Upvotes: 0

StarGeek
StarGeek

Reputation: 5791

Result from the thread on the exiftool forum

output <- system(sprintf("exiftool -GPSLatitude=%f -GPSLongitude=%f %s",q,p,aa))
or
output <- system(paste("exiftool -GPSLatitude=",q," -GPSLongitude=",p," ", aa))

Upvotes: 4

Greg Zaal
Greg Zaal

Reputation: 273

In exiftool 12.44+ you can now simply specify the decimal coordinates and it'll convert these to the appropriate meta tags, including reference direction:

exiftool -gpsposition="-25.40424,27.73621" image.jpg

exiftool image.jpg | grep GPS
GPS Version ID                  : 2.3.0.0
GPS Latitude Ref                : South
GPS Longitude Ref               : East
GPS Latitude                    : 25 deg 24' 15.26" S
GPS Longitude                   : 27 deg 44' 10.36" E
GPS Position                    : 25 deg 24' 15.26" S, 27 deg 44' 10.36" E

Upvotes: 0

7Tonin
7Tonin

Reputation: 89

In order to deal with latitude and longitude possible negative values, I suggest to first import in XMP, then copy from XMP to EXIF : (bash code)

exiftool -XMP:GPSLatitude="$latitude" -XMP:GPSLongitude="$longitude"  "$image"
exiftool "-gps:all<xmp-exif:all" "-gps:all<composite:all" "-gpsdatestamp<gpsdatetime" "-gpstimestamp<gpsdatetime" "$image"
exiftool -EXIF:GPSAltitude="$altitude" -EXIF:GPSAltitudeRef#="0" -EXIF:GPSMapDatum='WGS-84' "$image"

Upvotes: 2

v010dya
v010dya

Reputation: 5858

When trying to do a similar thing as suggested by Casto Salobreña i got the following error:

$ exiftool -XMP:GPSLatitude=1.2843265 -XMP:GPSLongitude=36.8798949 -GPSLatitudeRef=South -GPSLongitudeRef=East -P test.jpeg 
Warning: Truncated PreviewIFD directory. IFD dropped. - test.jpeg
Error: [minor] Bad PreviewIFD directory - test.jpeg
    0 image files updated
    1 files weren't updated due to errors

to fix this i have dropped the Ref options removing and by changing the South direction (or potentially would need to do the same for West) to a negative number:

$ exiftool -XMP:GPSLatitude=-1.2843265 -XMP:GPSLongitude=36.8798949 -P test.jpeg 
    1 image files updated

now i test:

$ exiftool -l test.jpeg
...
GPS Position
    1 deg 17' 3.58" S, 36 deg 52' 47.62" E
...

Upvotes: 1

Casto Salobre&#241;a
Casto Salobre&#241;a

Reputation: 81

To add the gps coordinates with exiftool:

exiftool -XMP:GPSLongitude="-84.683333"  -XMP:GPSLatitude="10.502117"  -GPSLongitudeRef="West" -GPSLatitudeRef="North" photo.jpg

The values are just floating point numbers as got from Google Maps for example.

Upvotes: 8

Related Questions