Flickr Photo Set to KML

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 – Some photos from Cape Cod.

    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::

  • 2011-10-06
  • 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.

47 Comments

  1. Great stuff!

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

  2. Pingback: Flickr photo set in google earth « Springerspaniel’s Weblog

  3. 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. That last sentence should say “It works when I replace ‘&’ with ‘&-amp-;’

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

  6. Pingback: Remote Sensing Tools

  7. 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. YESSSSS! This is superb, you make me very happy!

    Thank you so much!

  9. 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?

  10. Pingback: La Cartoteca » Blog Archive » Flickr - De álbumes a KML

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

  12. 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.

  13. http://www2.adamfranco.com/photosetToKML.php doesn’t work for me. What am I doing wrong? I just insert the ID and get a KML-file that doesn’t contain links to my pictures.

    ID is 72157601889331278

  14. 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. Very nice tool. This all certainly evolve over the last few years.

    Cheers,
    Dmitri

  16. Pingback: flickr on google maps at this year.

  17. 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. Aaagh… brackets stripped out of previous reply…

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

  19. Pingback: SK » Flickr photoset via KML auf Google Maps

  20. Pingback: Geotagging & sharing photos: easy, free, standard-based « Mi estero

  21. 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. 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. 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. Pingback: Limmen National Park | this year.

  25. 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. 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. 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. Is posible one of a flickr group with autorefresh???

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

  30. Thank you so much for sharing your flickr photo set to kml website. It works great! It does exactly what I needed it to do. I want a kml file with all of the photos that have been posted on our photo blog, and now I have it. Thank you!! I’ll be posting the kml file at the bottom of this post:
    http://14lenses.blogspot.com/2008/08/14-lenses-map.html

  31. Nice Work, thankyou for this article, regards from argentina!!

  32. Hi! I was surfing and found your blog post… nice! I love your blog. 🙂 Cheers! Sandra. R.

  33. It’s surprising that over 2 years later, this script still seems to be the only option (even among paid apps!) to perform this simple yet neglected function.

    After days of searching, and almost tackling the coding myself, I finally entered a fruitful search term into Google and found this!

    Thank you so much!

  34. DITTO to all the praise above! Your script is amazing, and I loudly repeat the previous comment:
    “2 years later, this script still seems to be the only option (even among paid apps!) to perform this simple yet neglected function.” THANK YOU!

  35. Pingback: links for 2010-06-05 | Michael Ong | On9 Systems

  36. Just wanted to say thanks for the photosettokml!

  37. Thanks for this Adam, great script. I really appreciate you hosting it yourself, though in due course I’ll most likely host it on my own servers. Keep it up!

  38. Hi Adam,

    I’ve been trying to use your online Flickr Photo Set to KML generator, but with no success with any set that I submit. It always returns an empty set. Is there now a problem with it? (Perhaps a change in the Flickr API?)

    Thanks in advance,

    Peter

  39. Neat. And many thanks – this works well.
    One potential enhancement – I’d love to be able to set a very simple icon – not the Photo one.

  40. @Peter: It seems to be working for me. Maybe you tried it at a point where something was hiccuping. Another possibility: This will only work with sets that are public.

    @David Brown: Great idea. I’m trying to decide if it is better to allow just an icon URL or enable full editing of the styles. In the mean time, if you want to customize the icon:

    1. Download the KML file and open it in a text-editor.
    2. Look for the Style block at the top:
    <Style id=”flickr_photo”>
    <IconStyle>
    <Icon>
    <href>http://maps.google.com/mapfiles/kml/pal4/icon46.png</href&gt;
    </Icon>
    </IconStyle>
    </Style>
    3. Change the href value to point at any icon you want. In addition to changing which icon is used, you can also specify how they are positioned (which part of the icon is anchored at the coordinates) and oriented as described in the KML documentation.
    4. Save the KML file and share it.

  41. Adam –

    Thanks for the advice on customising Icons. I’ve also come across http://pmaps.taurich.org/cgi-bin/print-kml.cgi which does something different (prints photos from a Google Map) but which also works well in conjunction with your utility for the application that I have. It has options for handling icons.

    Regards, Dave.

  42. Any chance you could make your flickr-to-Google-Earth script into a program that turns geotagged photos into .kmz’s and works on a stand-alone machine without internet access? Doing so, and sending it to me, would make you easily the most awesome person in human history.

  43. Pingback: Google Mapping a Flickr Photo Set - CogDogBlog

  44. Great idea. Now if I can only figure out how I can put something like that on my website.
    Perhaps doing the same with satellite images instead.

  45. Awesome! I love this! Just wondering if there is a way to have it convert flickr Galleries into kml? I have a great gallery of photos in my town taken by different people I would love to show on a map. Thanks!

  46. Has anyone tried this lately? I think google maps no longer support this.

Leave a Reply to Adam Franco Cancel reply

Your email address will not be published. Required fields are marked *