Flickr Photo Set to KML

Adam Franco August 23rd, 2007

One of the things I (and others) have found lacking when working with geotagged images on Flickr, is the inability to retrieve a “photo set” (Flickr’s take on a slideshow) as a KML document that can then be displayed in GoogleEarth, GoogleMaps, or other geo-browsers. Flickr provides some KML links and GeoRSS feeds, but these are either limited to 20 items or can only be pointed at tags or users’ photo-streams, not a particular photo set.

To fill this niche, I present a small script I wrote to generate a KML file from the geotagged photos in a set:


Photo Set to KML     (try it out)


Features:

  • Generate a KML file from a Flickr photo set
  • Directly open the KML file in Google Maps
  • Choose what size image to include in the placemark description for each photo.
  • Optionaly draw a path (line) from photo to photo ordered in one of several ways: by date taken, by date uploaded, by set order. Useful for making a quick and dirty map of a trip.

Examples:

  • KML / GoogleMaps - A nice set of graphitti in Toronto.

    View Larger Map
     
  • KML / GoogleMaps - A set of photos from a trip I took around Turkey, with lines drawn chronologically. Since this is a large set that causes GoogleMaps to time-out, I’ve downloaded the KML file and then re-uploaded it to my website. This is the method I recommend for large photo sets.

    View Larger Map
     

You are welcome to use this script hosted on my site, or you can download it and run it on your own computer/webserver. If you would like to run it yourself, please be aware of the following…

System Requirements:

This script is available under the GNU General Public License (GPL) version 3 or later. (Source Code)

Updates::

  • 2007-08-27
    • Now uses htmlspecialchars() to clean titles instead of htmlentities(), the latter of which was causing excessive translation of German characters. Thanks Stefan Geens, for pointing this out.
    • Form now generates valid XHTML 1.0 strict.
    • Now can use image thumbnails instead of camera icons. Thanks for the idea Nicolas Hoizey.
  • 2007-08-24
    • Now escapes ampersands in titles and descriptions. Thanks Jesse for pointing this out.

    Future Improvement Ideas::

    • Add an option for icon size.
    • Add options for custom icon/path styles. I’m not sure whether to give several options, or just provide a field for a block of arbitrary KML style-markup.

29 Responses to “Flickr Photo Set to KML”

  1. Nicolas Hoizeyon 24 Aug 2007 at 7:42 am

    Great stuff!

    It would be even better with the square format images used instead of the purple cameras…

  2. [...] Questo e´ il link al post di Adam Franco: Flickr Photo Set to KML [...]

  3. Jesseon 24 Aug 2007 at 5:17 pm

    Great work! This will be a great way of sharing my photos!
    Just one small issue: when the name of a photo has an ampersand in it, Google Earth treats it as an invalid KML file. It works when I replace ‘&’ with ‘&’.

  4. Jesseon 24 Aug 2007 at 5:18 pm

    That last sentence should say “It works when I replace ‘&’ with ‘&-amp-;’

  5. Adam Francoon 24 Aug 2007 at 10:50 pm

    Thanks for pointing this out Jesse, this bug has been fixed.

  6. Remote Sensing Toolson 25 Aug 2007 at 1:19 pm

    WordPress Plugin, Google Maps Quicktag…

    Since Google Maps can now be ‘embedded’ in a similar way to YouTube and Google Videos, I decided to create a basic plug-in for WordPress users and share it with whoever might think it’s useful. All it is, is a simple addition of a but…

  7. Jonon 25 Aug 2007 at 4:34 pm

    This is a wonderfully nifty tool. I agree with Nicolas Hoizey, if theres a way to replace the icons with square images that’d be awesome. Will definately use again!

  8. Miekon 26 Aug 2007 at 12:15 am

    YESSSSS! This is superb, you make me very happy!

    Thank you so much!

  9. Christianon 28 Aug 2007 at 3:09 pm

    Great work! Thanks!

  10. Matidioon 29 Aug 2007 at 8:30 am

    Hi,

    fantastic tool! I was experimenting a lot with it and I thought why limiting the script only to a set …
    For obvious reasons the output is limited to public photos. But if I wanted to show someone the photos of a guest pass on a map? One could use the guest pass feature of Flickr.

    The syntax of a guest pass is http://www.flickr.com/gp/user@id/xxxxxx

    Obviously only the Flickr user knows the correct values (or the ones which received the guest pass)

    So maybe changing a little bit the input form (and the script) this should be feasible.
    If this worked out it would be great.

    What do you think?

  11. [...] Flickr Photo Set to KML [...]

  12. Jonon 31 Aug 2007 at 6:52 pm

    WOW! You added the square thumbnail icons! When you come to Calgary, I’ll buy you the beverage of your choice. Thanks!

  13. Adam Francoon 04 Sep 2007 at 8:44 pm

    Re: Matidioon and guest passes:

    From my perusing of the Flickr API I have not found any mention of authorizing access to certain photos according to guest passes. The guest passes seem to not be available in the API, therefore, I don’t think I’ll be able to add support for browsing private photo sets via a guest pass.

    If I am wrong and anyone can point me to documentation on using guest passes with the API, then I’d love to add this feature.

    Another option would be to enable an ‘authenticated’ mode of working that would allow access to any photos a user has access to, though that might add some complication when accessing the KML url directly from within Google Earth.

  14. Lukeon 16 Sep 2007 at 7:00 am

    First of all, great script, it was just what i was looking for. I have a small request though. Would it be possible if the tag is missing from the photo, to look into the standard tags for the co-ords instead.
    My reason is i am going to be uploading some photos from my phone and manually geo tagging them, and i would like to be able to drop them onto a map.

  15. Toronto Photographeron 17 Sep 2007 at 1:53 am

    Very nice tool. This all certainly evolve over the last few years.

    Cheers,
    Dmitri

  16. flickr on google maps at this year.on 21 Sep 2007 at 7:21 pm

    [...] a kml for them that can then be viewed in Google Earth or on Google Maps. The code was written by Adam Franco and can be run from his site, or you can host it on your own [...]

  17. Peter Roseon 01 Oct 2007 at 8:20 am

    How about an option to set the icon scale to use the full resolution of the flickr thumbnail?

    2

    This gives a normal size of 67×67 pixels, which becomes 75×75 on mouseover.

    Also, (being fussy) it would be handy to be able to set all the photo titles to blanks, and just show the icons themselves (I know I rarely bother to name each individual file)

    Worst case I’ll just keep doing these myself with find and replace… Other than that, it’s a great little piece of code.

  18. Peter Roseon 01 Oct 2007 at 8:22 am

    Aaagh… brackets stripped out of previous reply…

    (IconStyle)
    (scale)2(/scale)
    (Icon)

  19. [...] ein Script von Adam Franco kann man seine flickr-photosets via KML auf einer Google Map darstellen - dazu einige [...]

  20. [...] Open API’s and ingenious outsiders to the rescue. Last August someone wrote a small online application that lets you enter your Flickr photo set id, and get a KML with photo thumbnails and a number of nifty options. The code is in PHP and is also open source and [...]

  21. godderton 17 Apr 2008 at 1:17 am

    Hi,

    seems your script has some difficulties at the moment. Choosing Google Maps as option and any other icon style than square leads to an error in Google Maps: File not found. The same if I switch on “Draw Line”. I can’t verify whether it is a time out problem of your server (means it doesn’t manage it to create the file in time) or anything else.

    By the the way this article has some difficulties with Firefox 3

    Thanks

  22. Adam Francoon 17 Apr 2008 at 7:17 am

    goddert,

    The problem is that GoogleMaps only waits a brief moment for the input KML file to load. If your set has too many pictures, then my script will take a few seconds to load and GoogleMaps will give you that ‘File not found’ error.

    To get around this limitation, use the option to download the KML file. Your browser will wait for the KML to load as long as needed. Once you have saved it to your desktop you can upload it to a website somewhere and link to it in GoogleMaps from there. Since at that point in only needs to be transferred to Google’s server, not processed, even larger sets should work.

    Thanks for the update about Firefox 3. I’ll look into that.

    - Adam

  23. Marcuson 06 May 2008 at 9:34 am

    Hi Adam,

    awsome script! Wow! The only thing thats need to get perfect would be using sets which are only for family and friends. Would it be possible to implement this?

    Greets from Hamburg,Germany
    Marcus

  24. Limmen National Park | this year.on 02 Jun 2008 at 6:32 pm

    [...] which accounts for the straight lines on the map. I used Adam Franco’s wonderful ‘flickr PhotoSet to KML‘ script to generate a KML of my photo set that I combined with the GPS data in Google Earth. [...]

  25. Javier Sanchezon 25 Jun 2008 at 4:17 am

    Great stuff!

    One idea for the future: a option to add a GPS track in the KML from a previous KML or GPX file.

    Best regards.

  26. Eric Schwarzon 19 Aug 2008 at 11:07 pm

    I was wondering if there would be a way to get this to work in my own API google maps, but the twist would be to get it to get my goups flickr pool to display instead?

  27. Mike Mileyon 28 Aug 2008 at 5:12 pm

    Thanks so much for putting that script together! I know you did it some time ago but it helped me out today.

    Our site is a wiki with google maps showing kml output from Google Earth. Your script lets me overlay photos from a corresponding set we have at Flickr…. something Yahoo can’t seem to figure out.

    While I put together an automated system for dynamically generating the kml, the files will be manually updated, but one step at a time. We will make sure to link back to you when we finish the “how-to” page.

    Thanks!

    http://shadowsoftrains.org/mediawiki/index.php?title=Test

  28. jacinon 02 Oct 2008 at 5:29 pm

    Is posible one of a flickr group with autorefresh???

  29. mayhemon 14 Oct 2008 at 8:37 pm

    ya, I am wishing for one that does group pools as well!!! PLEEEEAAAAZZZZEEEEE!!!!

Trackback URI | Comments RSS

Leave a Reply