I have a bunch(around 400) 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 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'm able to do it using the terminal with the following command
exiftool -GPSLatitude=19.131843 -GPSLongitude=72.91783 20161013_121101.jpg
where 20161013_121101.jpg is the image name.
But in R program, I need to take a batch of jpeg images and need to edit the GPS location, so I wrote it as
output <- system("exiftool -GPSLatitude=19.131843 -GPSLongitude=72.91783 aa") values are considered as an example
where aa is dynamically changed with the name of jpeg files. Now the problem is exiftool is considering aa as the filename and showing an error
Error: File not found - aa
I'm using Mac osX sierra.
Can anyone help me.
Thanks
ExifTool will do the time interpolation for you if the GPS track is stored in a recognized format. See the -geotag option for details.
But to fix your R problem, try specifying the full path to the file instead of just "aa". I don't know what the working directory is set to when you shell out a command from R, so specifying the full path avoids this question.
- Phil
aa itself is having the full path
ie I'm dynamically putting the pathname to aa=/Users/bibinwilson/Dropbox/Research/LabWork/test/20161013_121103.jpg
in the next iteration, it will be aa=/Users/bibinwilson/Dropbox/Research/LabWork/test/20161013_121104.jpg etc
is there any provision to do like this? first time I'm using exiftool. please help me
Then I don't understand why ExifTool can't find the file.
Quote from: bibinwilson on January 25, 2017, 09:10:06 AM
is there any provision to do like this?
I don't know what you mean.
- Phil
I mean, is it possible to do like that. Otherwise can I do it in any other alternative manner?
To do like what? Iterate over multiple files? Sure.
May I know how it's possible?
exiftool -geotag track.gpx DIR
QuoteNow the problem is exiftool is considering aa as the filename and showing an error
Error: File not found - aa
I know nothing about R (didn't even know about its existence) but it seems to me that your command isn't passing the value of variable aa, it's passing the constant "aa".
A quick search and I came across this StackOverflow (//http://) answer which seems to indicate that this is the problem. It looks like your code should be
output <- system(sprintf("exiftool -GPSLatitude=19.131843 -GPSLongitude=72.91783 %s",aa))or
output <- system(paste("exiftool -GPSLatitude=19.131843 -GPSLongitude=72.91783 ", aa)) Having said that, if your coordinate data is in a geotrack format that exiftool already understands, you're going to see an huge increase in speed if you run a single exiftool command like Phil suggests rather than loop and execute exiftool ever time (see Common Mistake 3 (http://www.exiftool.org/mistakes.html#M3)).
Also, if any of your gps data is negative (Southern or Western hemisphere), then you also need to set the
GPSLatitudeRef and
GPSLongitudeRef tags, otherwise your results will show up in the wrong part of the world.
Thank you so much. You saved my life. Can you help me out in one more thing. I tried a lot. Now I removed the exact values given with a variable name
ie I stored 19.131843=q and p=72.91783. I did this to make dynamic nature, ie, p and q value will change in every iteration.
so my code looks like :
output <- system(sprintf("exiftool -GPSLatitude=q -GPSLongitude=p %s",aa))
But now GPS (lat lon) values changes back to (0 0)
Is there any way to rectify this.
Thank you
This is the same problem as before: The p and q in your solution are taken as literal, not the value of variable. Replace them with %f (or whatever R uses to denote a floating point) and replace aa with q, p, aa.
Note that I have never programmed in R before, but this is a basic programming thing (i.e. the difference between variables and string literals).
I'm just guessing based upon the link, but try
output <- system(sprintf("exiftool -GPSLatitude=%f -GPSLongitude=%f %s",q,p,aa))
or
output <- system(paste("exiftool -GPSLatitude=",q," -GPSLongitude=",p," ", aa))
Edit: If this works, don't forget to go back to StackOverflow and select the answer. More sweet internet points for me! :D
Thank you sooooooo much guys...... Now I can rest in peace!!!