Hack 10. Georeference Digital Photos

Have you ever looked at someone's photo album and wondered where the photos were taken? Using your GPS and digital camera, you can figure out just that, and it's easier than you think.

If your digital camera allows you to set the time, you can use tracklogs from your GPS to add latitude and longitude information to your digital pictures. Since every photo you take with your digital camera contains the time the photo was taken, your computer can use the time a picture was taken to look through the GPS tracklog to find out where you were when you took the photo. As long as the GPS is on and storing tracklogs while you take your photos, you can link the photos to their respective locations.

To start out, just like two robbers about to heist a bank, the digital camera and the GPS need to have their internal watches synced. Since the GPS picks up the current time whenever it locks onto a satellite, it will always be dead-on. The only problem with this method is that if you change time zones, you have to resync your camera's time, since the camera isn't quite as clever. Next, make sure your GPS has a lock on your location, and carry it with you as you photograph. See [Hack #58] for tricks on saving your tracklogs.

The GPS will record your tracks, giving you a record of your movement that can be later downloaded to your computer. Using the common bit of information, the timestamp, various programs can match up the photos to their respective locations. For the PC, there is Microsoft's free World Wide Media Exchange (WWMX, available at http://www.wwmx.org/), RoboPhoto ($35, at http://robophoto.com), RoboGeo ($22.95, at http://robogeo.com), Quakemap ($10, at http://www.earthquakemap.com/), and TopoFusion ($40, at http://www.topofusion.com/). You can also use purely web-based services such as GeoSnapper.com or Thingster.com.

Alternatively, and for less than $950 USD, you can get a camera that will do the linking for you. These cameras have built-in GPS receivers or have GPS attachments. As of this writing, you can purchase the older 1.4 mp Kodak DSC 260 series, the costly Nikon DSLR cameras (D1x, D1h, Pro 14n, and Pro SLR/n), or the impressive new Ricoh "Caplio Pro G3" with GPS card. With the cost of GPS chipsets decreasing, more cameras, and even camera phones, are getting into the act. Already the Japanese AU camera phone can take georeferenced images, and other Japanese camera manufacturers are adding GPS to attract new patrons. U.S. camera phones are enabled to find your location in case you call 911, so I hope next year's smart phones will start including this feature.

1.11.1. How Does This Work?

Digital cameras save extra information about each picture within the image file in an EXIF header. This includes the date and time when the image was taken. You can explore this information with the free program Exifer for Windows, available at http://www.friedemann-schmidt.com/software/exifer/. RoboPhoto, discussed earlier, also allows you to view EXIF headers. If you are willing to use Perl, you can install the Image::EXIF module from CPAN (from a terminal window in Linux or OS X; typing sudo perl -MCPAN -e install Image::EXIF will probably do it). This bit of Perl will dump the EXIF headers from images that you specify:

#!/usr/bin/perl
 
use Image::EXIF;
use Data::Dumper;
 
foreach my $file (@ARGV) {
 my $exif = new Image::EXIF($file);
 print "file: $file " . Dumper($exif->get_all_info($file));
}

Call it with one or more image names on the command line:

$ exifdump.pl DSC_3044.JPG 

For my images, this returns 60 lines of technical information about the image, including details on the exposure and metering modes. Among this embarrassment of Metadata riches is the Image Generated field. This tells us when the picture was taken:

'Image Generated' => '2004:09:01 19:27:35',

In database terms, "Time is the universal foreign key." Assuming we are tracking the same thing, we can use the time that things occurred to synchronize information from different devices. So our GPS tracklog has our location timestamped at regular intervals, and our camera timestamps our images. All of the programs that do GPS timestamp image interpolation either pick the closest point, based on time, or they pick the two closest points and return the point where you would have been if you were going a constant velocity between the two points.

The simplest way is to do a straight interpolation. Assume you have these track points (exaggerated in order to make the math easier):

38.4 -122.1 2004-09-20 12:20:43
38.5 -122.2 2004-09-20 12:23:53

And you have a picture that was taken at 12:21:47 (let's assume your photos are timestamped in UCT to match the GPS tracklog). Where were you when you took that picture? There are two techniques that give reasonable answers for small distances. The easiest way is to calculate the time difference between your two points (190 seconds) and the percentage of that represented by your target time. 12:21:47 is 64 seconds past the start time of 12:20:43, or 64/190 = 34% of the way. Then the (approximate!) point at 12:21:47 is:

Lat = 38.4 + .34 * (38.5 - 38.4)
Long = -122.1 + .34 * (-122.2 - (-122.1) )

This technique has the advantage of being simple, and for this distance, it is reasonably correct. In [Hack #11] we explore a sample Geo-enabled Excel spreadsheet. Within that workbook, the sheet titled Georeference provides a simple form that lets you georeference one image at a time. It also demonstrates another approach to interpolating based on time by calculating the bearing between the two reference points and then calculating the lat/long at a given distance from the initial point along that bearing.

1.11.2. Aim and Composition

Now that you know how to get your photos GPS enabled, what are you going to do? You could use it for scientific purposes like a botanist friend of mine, or take a photo of your storefront to help customers find your business. Real estate, hiking, sailing, driving, and skydiving are all other areas that geo-imagery would apply to. On the other hand, you might want to get personal, with a point-of-view camera mounted on your head. Another aim might be to give "visual" waypoints to a meet-up point for a private party. With the advent of camera phone technology, geo-images may be adopted by protest leaders to organize massive flash mobs. Imagine your cell phone company offering services to show highly rated geo-images near your current location, along with directions to the spot. As any photographer knows, an image can hold a thousand words, and three coordinates: latitude, longitude, and altitude.

1.11.3. Conclusion

Whatever your purpose, georeferenced images can provide important details to a photo and interesting tidbits to your audience. Sharing said photos could help map the world, as others may have things to say about the places you photograph. My hope is that camera companies like Ricoh will flourish as a result of photographers publishing their results, and wireless providers will start offering this simple service. Once you get the hang of taking geo-images, share your photos for a better view of the world and the people who make it so impressive.

Tom Longson





Mapping Hacks
Mapping Hacks: Tips & Tools for Electronic Cartography
ISBN: 0596007035
EAN: 2147483647
Year: 2004
Pages: 172
Simiral book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net