Hack 96. Share Geo-Photos on the Web

Share your geo-referenced images with the web-wide world in various forms.

Once, with some help from [Hack #10], you've gotten the hang of producing georeferenced photos, you'll want to take the next step by publishing them to your web site or to other collaborative photo services. As the geo-photo community has grown, so has the list of ways to publish your photos for others to see.

GeoSnapper (http://geosnapper.com/) and WWMX (http://wwmx.org/) are both services that try to ease the GPS-linking problem by providing tools to process your raw tracklog and photos. WWMX is a Microsoft product and works really well, but is based on the .NET framework, so it will only run on modern Windows operating systems. GeoSnapper works as a web service, and it will work for you as long as you have your tracklogs downloaded to your computer as Garmin MapSource or MacGPS Pro formats. [Hack #51] discusses GPSBabel, an excellent free cross-platform program that will simplify downloading tracks from your GPS and converting them between different common formats. It comes highly recommended!

http://locative.us/photomap/ holds the two Perl scripts that we wrote to produce photo maps and publish spatial metadata about photographs on the Web. The process happens in two parts. First, we create an RDF feed of metadata that describes the images and tags them with place and timestamps. Second, we use the RDF feed to plot the photographs over a base-map layer. Visit http://locative.us/photomap/ to download the two scripts, one named geoloc_media.pl and the other plot_rdf.pl. To run them, you need to have several Perl modules installed from the CPAN code archive: Geo::Track::Log, SVG, Image::EXIF, XML::Simple and RDF::Simple. [Hack #97] offers detailed instructions on the easy process of downloading and installing Perl code from CPAN. If you've been working through the hacks in this book, you'll have most of these modules installed already.

9.5.1. Create an RDF Feed of Photo Metadata

The first Perl script, geoloc_media.pl, takes a set of images and a GPS track in GPX format and spits out an RDF description of the images, annotated with time and place stamps and the creator's details.

This script assumes that you have a directory full of images that were taken while recording a tracklog with your GPS. You need to provide an address where that directory is available on the Web; this helps to uniquely identify different pictures and allows others to make descriptions of them.

The script needs to be run with several parameters:

perl geoloc_media.pl ...

Take a picture of your GPS showing the current time when you start a trip. This will allow you to check that your camera and GPS are synchronized, and to calculate the offset later if they are not.

Here's a sample run of the geoloc_media.pl script:

 

perl geoloc_media.pl

2.5

http://frot.org/20041020/ 20041020.gpx zool@frot.org /www/frot.org/20041020/* > photos.rdf

The end of this sequence, > photos.rdf, sends the output of the script to a file. What the script spits out is a set of locative packets that describes the photographs: where they were taken, when they were taken, and who took them. See [Hack #95] for advice on modeling spatial information in RDF. Here's a short sample of an RDF description of photographs taken in Utrecht, September 2004:

5.125718 52.084616 20040906T134632

In English, this description says, "Here is some context about a point in space at latitude 5.1257 and longitude 52.0846. There is a piece of media attached to it. The piece of media was created at this time, and the person who created it has the email address zool@frot.org."

9.5.2. Create a Dynamic SVG Map with Pop-Up Photographs

Now that we have all that nice photo metadata, what can we do with it other than share it? One quick way to see your photos in relation to a map is to plot them on it using the Scalable Vector Graphics (SVG) format.

The second script, plot_rdf.pl takes the RDF/XML file output by the first script and another file describing a base map with its orientation, and overlays the photos on the map.

This is a slightly more complex task, as first we have to acquire a base map and know how it is georeferenced. That is, we need to know the coordinates of the top left corner, what the extents of the image represent in terms of geographical space, and how the map is skewed or rotated with respect to True North. What a mouthful!

Luckily, we've already thought of this, and [Hack #33] demonstrates the appropriate technique. The JavaScript-based client provided for the hack, available at http://mappinghacks.com/georeference/, allows you to figure out the spatial extent of an image, provided that you have three known points that you can identify on it. The client spits out a series of six numbers known as an affine transformation, which shows how your map is projected in relation to geographical space.

Use the six numbers to create an XML file that looks like the following example, providing a simple description of your map image: its name, its size, and the transformation that the map went through in relation to geographical space. This is the XML file that was used to create a photo map for the GPS/photo info mentioned earlier:

utreg.gif 890 684 10000 0.549457004709508 -0.0298986308382459 0.0250666506000045 -0.52601105571061 -2699.47952280242 2028.02835472852

Finally, you're ready to create a SVG photo-overlaid map. Take the second script, plot_rdf.pl, and run it with the XML image file as the first parameter, and the RDF description of your photographs as the second. It will spit out an SVG file that uses your map as a base layer and has an icon for each photograph, which expands to show a photo thumbnail when you move your mouse over it, as shown in Figure 9-8:

perl plot_rdf.pl utreg.xml utreg.rdf > map.svg

Figure 9-8. A dynamic map with photos appearing as tooltips

The art of georeferencing hypermedia and publishing it to the Web continues to be a fast-changing and complex field of activity. In addition to the experimental scripts described in this hack, we have begun work on a project known as the Locative Media Toolkit that will bring together the tasks of downloading GPS traces, rectifying base maps, georeferencing digital media against GPS tracks using timestamps, annotating locations with text and other information, and then finally publishing to the Internet in various human-interactive and machine-readable formats, all under one neat Open Source GUI application designed to run interchangeably on Windows, Mac OS X, and Linux. Can it be done? Find out more about the Locative Media Toolkit at http://mappinghacks.com/projects/lmt.

 

9.5.3. See Also

http://www.akuaku.org/archives/2004/10/bluetooth_gps_m.shtml

Dav Coleman's write-up of taking geo-annotated photos in real time using a camera phone and a Bluetooth GPS

http://flickr.org/

Flickr, a photo-sharing site

http://geolicious.com/

Geolicious, a spatial-media-annotating site.

http://www.akuaku.org/archives/2003/05/gps_tagged_jpeg.shtml

GPS EXIF metadata

http://mappr.com

Mappr, a tool for georeferencing Flickr photos by looking up tags in a gazetteer of world place names

Категории