简体   繁体   中英

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

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.

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))

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
...

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM