Author Topic: Tips for print format file to generate Google Earth KML for geo-tagged photos  (Read 3654 times)

Kohekohe

  • Newbie
  • *
  • Posts: 5
1. A great starting example is at the bottom of http://www.sno.phy.queensu.ca/~phil/exiftool/geotag.html

2. Not all your photos might have geo-coordinates, so you can add  -if "$gpslongitude ge 0" to the exiftool command line parameters to process only the files that have geo-coordinates.  That way your KML list of photos in Google Earth doesn't become cluttered by the photos without coordinates.

3. -r -fileOrder DateTimeOriginal are handy exiftool parameters to go through a whole directory structure of photos and end up with a KML that's sorted by photo date!
I just run the exiftool command from the top level and specify . (a dot = current directory) as the starting point.  Leave the KML output file in the same top level directory and Google Earth will find your local image files.

4. If you have lots of photos, the names of them on all the placemarks end up cluttering Google Earth.  Replace the
Code: [Select]
#[HEAD]    <Style id="Photo">
...
#[HEAD]    </Style>
with the following StyleMap of two styles so that the photo name is hidden (LabelStyle scale 0) unless you hover over the placemark or select it.  This is much neater if you have lots of placemarks/photos:
Code: [Select]
#[HEAD]    <Style id="Photo_normal">
#[HEAD]      <IconStyle>
#[HEAD]        <Icon>
#[HEAD]          <href>PhotoPin.png</href>
#[HEAD]          <scale>1.0</scale>
#[HEAD]          <hotSpot x="0.5" y="0" xunits="fraction" yunits="fraction"/>
#[HEAD]        </Icon>
#[HEAD]      </IconStyle>
#[HEAD]      <LabelStyle>
#[HEAD]        <scale>0</scale>
#[HEAD]      </LabelStyle>
#[HEAD]    </Style>
#[HEAD]    <Style id="Photo_highlighted">
#[HEAD]      <IconStyle>
#[HEAD]        <Icon>
#[HEAD]          <href>PhotoPin.png</href>
#[HEAD]          <scale>1.0</scale>
#[HEAD]          <hotSpot x="0.5" y="0" xunits="fraction" yunits="fraction"/>
#[HEAD]        </Icon>
#[HEAD]      </IconStyle>
#[HEAD]      <LabelStyle>
#[HEAD]        <scale>0.75</scale>
#[HEAD]      </LabelStyle>
#[HEAD]    </Style>
#[HEAD]    <StyleMap id="Photo">
#[HEAD]      <Pair>
#[HEAD]        <key>normal</key>
#[HEAD]        <styleUrl>#Photo_normal</styleUrl>
#[HEAD]      </Pair>
#[HEAD]      <Pair>
#[HEAD]        <key>highlight</key>
#[HEAD]        <styleUrl>#Photo_highlighted</styleUrl>
#[HEAD]      </Pair>
#[HEAD]    </StyleMap>
Note: In the above code, I use a local image file "PhotoPin.png" for the placemark icon with the hotspot halfway (0.5) across the bottom (0) of the icon image, and I've also reduced the label text size to 0.75 scale (for the highlighted style, where the text is actually shown).

5. When you click on a placemark and it shows the photo, I like having the date underneath the photo.  What is displayed in the popup in Google Earth is basic HTML, so you can simply add another table row below the image: ...</td></tr><tr><td>$DateTimeOriginal</td></tr>
If you do that, but aren't happy with the default format, you can specify a different format via an exiftool command line parameter, e.g. -d "%d %b %Y %I:%M %p" gets you 30 Sep 2015 11:32 a.m.

If you don't want leading zeros for the day or hour, then add a minus sign after the %, e.g. %-d  (if you use Windows, use a # instead of the minus sign).  See http://strftime.org/ for a complete list of date/time format options.

Note: You could display any exiftool variable here (f-stop, shutter speed, whatever!) - how awesome is that?!

6. In the example file, the placemark labels display the filename (<name>$filename</name>).  To make it a bit neater, you can strip the .jpg extension, and also change '&' to '&amp;' if you have any ampersands in any filenames, otherwise the HTML complains:
<name>${filename;s/.jpg//g;s/&/&amp;/g}</name>

7. Keep in mind that what's displayed in the popup is basically HTML.  So, you can do things like limit the size of the image shown, so it doesn't end up having scroll bars by adding an inline CSS style, e.g.
<img src="$directory/$filename" style="max-height: 900px" />

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 13735
    • ExifTool Home Page
Awesome!  Some very useful tips!  I have added a link to your post from the Geotagging page.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).