Flickr Photo Set to KML

August 23rd, 2007

Filed under: Computers and Technology , Software

Tags: , , ,

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 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. MagicPhantomon 09 Sep 2007 at 3:57 pm

    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

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

  16. Dmitri Markineon 17 Sep 2007 at 1:53 am

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

    Cheers,
    Dmitri

  17. 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 [...]

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

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

    Aaagh… brackets stripped out of previous reply…

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

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

  21. [...] 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 [...]

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

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

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

  25. 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. [...]

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

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

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

  29. jacinon 02 Oct 2008 at 5:29 pm

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

  30. mayhemon 14 Oct 2008 at 8:37 pm

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

  31. Heather Dowdon 25 Oct 2008 at 10:03 pm

    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

  32. Christian Gonzalezon 26 Mar 2009 at 9:58 am

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

  33. sandraron 10 Sep 2009 at 8:45 am

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

  34. Josh Jellelon 08 Feb 2010 at 2:12 pm

    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!

  35. kathleenon 25 Mar 2010 at 10:30 pm

    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!

  36. [...] Adam Franco.com » Blog Archive » Flickr Photo Set to KML (tags: flickr kml geotagging photography maps mashup google photos) [...]

  37. Mike Pon 23 Jun 2010 at 8:03 pm

    Just wanted to say thanks for the photosettokml!

  38. Jeremyon 24 Aug 2010 at 11:55 am

    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!

  39. Peteron 30 Aug 2010 at 6:07 am

    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

  40. David Brownon 13 Oct 2010 at 3:46 pm

    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.

  41. Adamon 14 Oct 2010 at 11:37 am

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

  42. David Brownon 14 Oct 2010 at 4:11 pm

    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.

  43. Johnon 14 Oct 2010 at 5:46 pm

    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.

  44. [...] through my old delicious bookmarks (OMG can you believe it still works???) and found this 2007 post Flickr Photo Set to KML by Adam Franco that has a tool to convert the data from a flickr set to KML, that can then be used [...]

  45. Wedding Photographeron 06 Apr 2011 at 1:35 am

    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.

  46. charleson 29 Jun 2012 at 1:48 pm

    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!

  47. Dan Brianon 22 Jul 2014 at 5:25 am

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

Trackback URI | Comments RSS

Leave a Reply