I’ve been over that page many times. The problem, and reason I want to write to XMP sidecar files is that all of my RAW files are read only, as they are checked into a program called git-annex upon import from my camera’s media. The XMP sidecar files are checked into git, so I have a version history of my files.
The commands on that page write the GPS info to the exit/XMP tags in the RAW file, which fails in this case (or even worse, exiftool copies the raw file before modifying the tags; this is bad as git-annex makes heavy use of symlinks).
Hi @clanmills, thank you for linking the article. It looks like that script works approximately the same as exiftools’ GPS functionality.
What I want to do is put my GPX file in the same directory as my CR2/NEF files, and then have a script or command that takes the GPX and CR2/NEF files, determines the GPS coordinates, and then writes those coordinates into the the XMP sidecar file, not into the image itself.
Writing the GPS coordinates is not possible in my currently workflow, as upon import from the camera medium, the image files are hashed then made read-only by a program called git-annex. I’m pretty fond of this workflow and I don’t really want to change it. I’ve also began checking my XMP sidecar files into git, so that I have a versonable history of things like darktable edits.
Thanks for clarifying your requirement. Good news, I think we have the code to fix this for you.
The code in the python script gps.py reads the GPX file and obtains the DateTime from the Exif data in the image. It interpolates the GPX file to determine the GPS coordinates. gps.py
You want to use the GPS coordinates to update the side-car, whereas I update various Exif GPS tags in the image. You can update sidecar files with the utility XMPCommand which is part of the Adobe xmpsdk.
There’s another change you’ll have to make to gps.py. That script uses pyexiv2 to connect python to libexiv2. pyexiv2 is not part of exiv2 and is now obsolete. You can obtain the date of the photo with exiftool, or the exiv2 command:
Eliminating pyexiv2 from gps.py is straightforward. You can execute exiv2 (or exiftool) with python’s popen3 and read stdout.
I’ve never used XMPcommand, however I’m confident that it can update your sidecar. You may prefer to use a XML utility such as xmllint to modify the sidecar.
We haven’t discussed your preferred scripting language. I used python for gps.py as an excuse to learn python when I wrote the script in 2008. I’m sure this can be readily converted to bash, perl or any preferred scripting sauce.
As it turns out, the above command works on my Debian Jessie install, but was problematic on my Fedora 23 laptop. I’m not sure why and don’t have the Fedora install still around to test it. I suppose I’ll be moving forward using that command now.