2 Replies Latest reply on Dec 2, 2012 5:49 PM by Minneapolis Glyn

    Setting EXIF:GPSLatitude and EXIF:GPSLongitude from a PlugIn

    Minneapolis Glyn

      The new LR4 mapping faclity is great, but I'd like to map the locations on my existing photos (over 20,000)..


      All my photos already have city/country information set as Keywords, and I am able to separately convert these locations to GPS coordinates via the Google Maps API.  (I have a standalone program to do this and dump the results to a CSV file.)


      What I can't work out is how to add this GPS information to the Adobe Metadata.  I could possibly try this outside Lightroom using EXIFTool or equivalent, but it should be possible to do it through the SDK.


      My current Plug in loads the GPS data, and then for each photo in the collection tries:




      This gets an assert failed message - presumably because GPS is not a valid Key.  LatandLongString is has the latitude with cardinal point (N/S) followed by the longitude with cardinal point (E/W) separated by a space.  (I also tried setting GPSLatitude and GPSLongitude separately). 


      Any ideas on the correct way to do this?



      (Incidentally, what is the correct way to get a collection by keyword?  My current code is:


      local thisKeyword = catalog:createKeyword( "Location1: " .. Location1, {}, true, nil)
      local photos = thisKeyword:getPhotos()


      but this also causes an error when trying to access the resulting photo array)


      Thanks in advance.



        • 1. Re: Setting EXIF:GPSLatitude and EXIF:GPSLongitude from a PlugIn
          johnrellis Most Valuable Participant


          The SDK documentation for photo:setRawMetadata() says:

          gps: (table) The location of this photo, for example, { latitude = 35.1, longitude = 86.7 }. Pass nil to 'unset'.


          So here's an example of correct values to pass:


          photo:setRawMetadata ("gps", {latitude = 35.1, longitude = 86.7})


          The first argument is the key, a string identifying the field, and the second argument must be a table of the form given above.

          • 2. Re: Setting EXIF:GPSLatitude and EXIF:GPSLongitude from a PlugIn
            Minneapolis Glyn Level 1


            thanks - I also got a similar answer from Jeffrey Friedl, and this works correctly.  I didn't see this in the documentation but maybe my web search didn't show up the latest version of the manual.


            With respect to the getting collection by keyword, I abandoned using the thisKeyword:getPhotos() construct.  Instead, I searched the catalog by keyword:


            local photos = catalog:findPhotos {
            searchDesc = {
                 criteria = "keywords",
            operation = "all",
            value = "Location1: " .. Location1,