Archives page

Posts Tagged ‘geotagging’

//TODO: Learn, play, discuss.

Somewhat inspired by Mike Taulty’s blog, I’ve decided I should throw my Tech TODO list at the world, because it might encourage / guilt me into doing some of them, as well as provide a preview on what this blog might be including over the next few months.

So all of these are technologies, packages, or platforms I want to be checking out in the not-to-distant future.  In no particular order, they’re bound to be added to as I go and quite possibly ignored as well.

  • .NET
    • ASP.NET MVC
    • ADO.NET Data Services
    • F#
    • IronRuby
    • Open-sourcing a simple XML resource provider (CodePlex)
    • .NET 4
      • Windows Communication Foundation
      • Entity Framework
      • Parallel Extensions
  • Gallery3
    • Module development
      • Migrate Twitter module
      • Migrate auto-GPS-tagging module
    • Theme development
  • Google Wave

Travel map – countries visited

I’ve been looking for a good countries visited map for quite some time. There’s something satisfying about painting the world red (or in this case, orange), and something humbling about seeing massive chunks of the planet untouched. So since we’re approaching April and I’m getting the inevitable itchy feet again, I’ve gone hunting.

Up until now, World66 had seemed my only option. But in the Age of Google, posting images for this sort of thing seems a bit of a letdown. Fortunately 29travels have just the thing with their Google Map version.

Pretty cool but it’s a shame there doesn’t seem to be an option to edit the map. But, a quick look at the iframe source, and you can see it’s pretty easy to hack in any new countries as you visit. Providing you know the right country codes of course.

http://www.29travels.com/getmap.php?j=ALATBACYCZDEESFRGBHRISITMKMTMENLPLSITRUSVAVN&c=cc41c9f2&w=575&h=300

That query string is a long list of 2-digit country codes. So, if you know the code for the country you want to add, just adding it to the string will provide all the highlighting you need. For example Australia = AU

http://www.29travels.com/getmap.php?j=ALATBACYCZDEESFRGBHRISITMKMTMENLPLSITRUSVAVNAU&c=cc41c9f2&w=575&h=300

Who wants to package this up into a WordPress plugin for me? 🙂

Automatically Geotagging your Gallery

Tags from Blakepics

Automatically add geonames.org tags to Gallery

As always, an imminent holiday has inspired me to update the entire system behind geotagging my photos.  Likewise, needing to plan said holiday has given me the opportunity to procrastinate and do something else instead.

Wishlist

  • A repository I can drop files created by the Genie BGT-31 GPS tracker.
  • Automatically convert the tracks into GPX format.
  • Automatically stamp any photos within Blakepics with their longitude / latitude values into the EXIF information.
  • Use that EXIF information to populate the database for the Gallery2 maps module.
  • Use geonames to get some basic tags, and automatically add those to the tags database.

I can happily report all of the above is happily running on a schedule on the Blakepics server.   Whilst I realise a lot of these options aren’t particularly available on a shared hosting server, I’m going to talk about them anyway.

A small disclaimer

Be under no illusion, a lot of these scripts are hacked together with no thought given to scalability, stability, or re-use.  They’d be a lot better off as a proper Gallery2 module to be honest – and hopefully someone will beat me to it in making that a reality.  However, for the time being – this is all provided as-is 🙂

NMEA repository

The repository is quite simple with an SFTP server running (sshd for example), and FileZilla on the client

Convert the tracks to GPX

  1. Install the rather excellent gpsbabel.
    yum install gpsbabel
  2. Run this convert-to-gpx.pl.txt perl script to combine all your nmea tracks to create a single gpx file.

Stamp the photos

  1. Get the gpsPhoto perl script.  You might find you need to install some perl modules:
    perl -eshell -MCPAN
    install modulename
  2. Use this geocode-photos.pl.txt script to find any matching photos from your Gallery, and tag them.  Note that I limit them to only photos I’ve uploaded myself, as I don’t want to go messing around with other peoples (and they were probably not at the same location anyway)

Fill the Gallery2 maps module with the EXIF data

There’s a maintenance task to use the EXIF data to power the maps module of Gallery2, so using Roel Broersma’s excellent script to run the maintenance tasks, these can be scheduled with the extra line:

wget --quiet --output-document=/dev/null --cookies=on --load-cookies $TMP_PATH/myg2cookies "$G2_URL/main.php?g2_controller=core.AdminMaintenance&g2_form%5Baction%5D%5BrunTask%5D=1&g2_taskId=PopulateGPSEXIFInfos&g2_authToken=$AUTHTOKEN"

Give some meaning to your location data with geonames

Geonames provides a reverse-lookup to get some more human readable descriptions of your photos.  So I use this to put in the country, region and town data into my Gallery.  You can go a bit further and get details of nearby landmarks from Wikipedia to add if you like, but i don’t find it too useful for my purposes.

  1. You’ll need some more perl modules
    perl -eshell -MCPAN
    install Image::ExifTool;
    install Image::ExifTool::Location;
    install Geo::GeoNames;
    install Data::Dumper;
  2. Get my write-geoname-tags.pl.txt perl script, which is actually a combination of all the previous scripts.  This will query the web service, and update your tags.

It all sounds very complicated…

Well, yes.  My aim isn’t to create the easiest system to set-up, it’s to create the easiest system to use.  Uploading a single NMEA track list now causes all of the above to happen automatically.  That said, I recognise that it’s not for the faint-hearted.

So why not try one of these easier solutions:

What next?

Add all of these scripts mentioned above to a cron task, and forget all about it.  You can probably combine the whole lot into a single job (I wanted to keep them separate, so some could be run nightly, and others weekly or monthly).

Hopefully this is the humble beginnings of a more efficient and elegant solution.  For now I’m at least getting a lot more data into and out of my photos

Do let me know if you make any improvements, or have any ideas for viable new features – I’d be interested to hear from you.

Geotagging with the Genie BGT-31

Don’t get me wrong, buying the Trackstick was a really good idea, it’s fuelled my interest in the location-aware Internet, it’s given me excuses to connect with other developers on Gallery2, had me writing geo-based modules, updates and hacks, and eased geotagging a whole bunch of photos.

But in the past two years, it’s also caused me to create and use some really really complicated geotagging techniques, frustration over forgetting what the flashing lights mean in Krakow, and aided and abetted in destroying one man’s Internet business in Split, even if just for a day.

Even the new Trackstick II’s still only boast a 1MB block of memory for storing tracks on, and I still need their proprietary drivers that caused me to destroy the book store/Internet Cafe in Split.  So for my next trip to Vietnam, I’ve bought the Genie BGT-31.  Granted, it’s almost twice the size of the Trackstick but contains a USB-chargeable battery which means no more carrying around stacks of AAA batteries and separate charger.

The built-in memory will store up to 20,000 records – but more importantly, supports SD cards, increases the measly 1MB into 1GB (thanks to the numerous cards lying around my flat and down the side of sofas).  These can taken out very quickly and dropped into the EEE where gpsbabel will convert the flat NMEA text format to whatever you might need … GPX, for example.

It also has a screen, so I no longer need to repeat the mantra constantly to myself in my head (or aloud) – “green for good, red for bad”.  Not to mention keep my blog posts updated with some more positioning (well, possibly).

So far the first impressions are good – and it will certainly tide me over until we can just tag the photos using our government-issue ID card’s weekly e-statements.

Geonaming your Geotags – Automatic picture captions

This time last year, I wrote about how to Geotag your photos using a simple GPS device and oodles of free software. Not much has changed in that process since, except now there’s a lot more software to choose from and the clever folks over at Trackstick.com have made it a lot easier to export your GPX tracks.

The spatially-aware web is producing a lot more services for us to use, and now Geonames.org some excellent reverse geocoding functionality. That’s the process of taking geo-data (such as longitude and latitude) and getting place names back. Which is really cool for tagging, titling or adding descriptions to your geocoded pictures.

They provide an impressive array of web services in both JSON and XML ranging from postal code searches, to reverse geocoding based on the community-based Wikipedia entries. And if that’s not enough for you, you can download a copy of their huge database and manipulate it off-line however you want.

So me, I wrote some JavaScript to take advantage of the reverse geocoding and tied it into the Blakepics Gallery2 Tags module. I’ll take the Wikipedia entries as an example, because that returns the most landmarks for me. The example code at the bottom of the page actually makes use of two more web services in addition.


The URL to call the web service is pretty simple enough:

var url = "http://ws.geonames.org/findNearbyWikipediaJSON?lat=" + lat + "&lng=" + lon + "&radius=10";

I’ve kept everything in JavaScript rather than building any back-end code whatsoever, so you need to make sure to use the JSON web services and take advantage of the script tags to avoid any cross-domain security policies. The JSONScriptRequest library can be a powerful ally here. This leaves my server to do more important things, but it all depends on your needs for the app.

url += "&callback=showWikipediaNames";
bObj3 = new JSONscriptRequest(url);
// Build the dynamic script tag
bObj3.buildScriptTag();
// Add the script tag to the page
bObj3.addScriptTag();

Then on the callback
function showWikipediaNames(wikijsonData) {
var wikiobjects = wikijsonData.geonames;
if (wikijsonData.geonames) {
for (var i=0;i<wikiobjects.length;i++) {
addSuggestion(wikiobjects[i].title)
}
}
bObj3.removeScriptTag();
}

With me so far? The final step in the process is to add the call to the JavaScript into your Gallery2 templates.

<a href="#" onclick="return showGeoNameOptions(this, {$block.gpsinfo.LoadGPSInfo.lat}, {$block.gpsinfo.LoadGPSInfo.lon});">GeoNames</a>

And before you know it, you have suggestions from geonames on how to tag your photos. Now you can go away and make it suggest some titles and descriptions too. If anyone’s interested in packaging this up into a slightly better Gallery module (or any other application), drop me a line. If this is enough for you, download my example and use it as you see fit.

Download

Pre-requisites