MENU 
Photos of GPS

My Geo-Tagging Workflow

February 28, 2019  |    0 comments  |  Apps GPS Logs Technique/Workflow

In my last post, wherein I outlined how I added a link to each photo’s location on Google Maps, I mentioned that I thought I’d done a writeup on how I geo-tag photos, but couldn’t find it. After extensive searching of the archives, I can confirm that I don’t seem to actually have ever written about my process. Today, I’ll rectify that oversight.

Let’s take a look at the tools I use, then I’ll walk you through how it all comes together.

First, we need a way to record a GPS log. Typically, these are in the format of a .gpx file, which is a type of XML file that can contain a geotrack, which is, at its most-basic, a series of GPS fixes in latitude and longitude along with a timestamp for each point that allows software to reconstruct a route. It may also, but not necessarily, contain speed and heading information. It can also contain a series of waypoints, which are GPS fixes that aren’t linked in a time dimension, so no track can be generated from these as there’s no way of knowing which order the GPS fixes/points were gathered, as order in the file doesn’t necessarily mean that’s the order they were gathered. In addition, we’ll need the time information later to match the time a photo was taken to a spot on our geotrack.

To build a .gpx file while out taking photos, we need a GPS receiver that has the ability to periodically record our current location in a file then export it for consumption by another tool to actually tag the photos. For this, I use a couple of different tools:

When I was using an iPhone as my day-to-day phone, I used an app called MotionX GPS to record my tracks.

Now that I’m using a Google Pixel 2 XL as my phone, I’ve had to find a different app to record tracks as MotionX GPS isn’t available for Android. I tried a few an eventually settled on GPSLogger. The UI isn’t as pretty as MotionX GPS, but it gets the job done.

The next tool we need is a way to merge the location and time data in our .gpx file with our photo data. Since I’m an Adobe Lightroom user (Classic, none of that CC nonsense for me!), I could use Lightroom’s rudimentary built-in geo-tagging feature (a tutorial can be found here), but I prefer some fine control over the process, so I use Jeffrey Friedl’s excellent Geoencoding Support plugin.

This allows us to fine-tune all sorts of fiddly bits in the process, such as correcting for the camera’s time being off a bit from the actual GPS time, which brings us to our next point:

How do I ensure that my time is correct on my camera?

There are a few ways to do it. If you’re lucky, your camera’s companion smartphone app supports synchronizing your phone’s time with your camera’s time, such as the Panasonic Image App (Android/IOS) does. If you’re not-as-lucky, you have to manually sync it, which means opening your camera’s settings and setting the date/time to match the phone’s as close as possible. Fortunately, it doesn’t need to be precise as most geotagging tools, such as Jeffrey’s Lightroom Geoencoding Support, allow for some “fuzziness” to the time matching algorithm.

Once you’ve tagged your photos, you can manually tag any misses in Lightroom’s Map tab. Now you have a precise log of your adventures and the photos you’ve taken.

In addition, you can open the .gpx file in Google Earth and get a nice map of your adventure. Here’s one from a visit I made to the Great Smoky Mountains last year:

So, there you have it, my geotagging workflow. However, I would be remiss in failing to mention that I’m currently testing using a GPS watch (the Suunto Traverse) for tracking as I don’t need to worry about killing my phone’s battery life while logging my location. So far, so good. I might do a write up in the future about my experiences with it.

How I Added Photo Location Data to 75CentralPhotography.Com

February 17, 2019  |    1 comment  |  Code GPS Logs Site-related

I like to geotag my photos. Almost every time I go on a phototrek/drive/adventure/walk, I log my locations so that I can merge my geotagged data with my photos and know exactly where each photo was taken. (I swear I thought I’d done a write-up on how I do this, but I can’t seem to find it. I have posted some of the track logs in the past however…you can see them here .)

Since I have this data sitting around and it’s embedded in each photo on 75CentralPhotography.Com, I thought it would be fun for visitors to the site to see exactly where in the world each photo was taken. But how to do this?

WordPress—the backend system for the site—helpfully provides a function to store EXIF data (basically the metadata in a photo that shows interesting things like shutter speed, aperture, ISO and a ton of other stuff) but only stores the basics, whereas the EXIF standard has scores of datapoints (colorspace, exposure bias, YCbCr positioning—whatever that is—to name a few). Unfortunately, this means that they don’t include location data as part of this limited scope.

Luckily, some kind soul has already solved part of the problem for us with a built-in function in PHP (WordPress’ programming language). This function, exif_read_data(), will let us read any part of a photo’s EXIF data and use it how we want. In this case, that would be to link to Google Maps and show a place marker of where the photo was taken.

Here’s how I leveraged that function to add a link on each photo’s page to the related location on Google Maps.

First, we need to get the photo’s EXIF data. Since exif_read_data() will only accept a local file as a parameter, we need to get the local path to the image relative to the page where we are executing the code/displaying the link. Fortunately, WordPress has us covered with a couple of functions: attachment_url_to_postid() and get_attached_file().

attachment_url_to_postid takes the URL of an attachment (i.e. a photo attached to a post) and returns the ID of that photo. To get the attachment’s URL, we use our old friend catch_that_image(), which resolves the URL of the first photo on a post (and, since we only ever post one photo at a time on the site, the only image on a post). Then, we take the result of that function and pass it to get_attached_file(), which returns the aforementioned local path of the photo file:

$attachment_id = attachment_url_to_postid( catch_that_image() );
$fullsize_path = get_attached_file( $attachment_id ); 

We then take this local path and pass it to exif_read_data() for parsing of the photo’s EXIF data:

$exif = exif_read_data($fullsize_path);

This function returns an array of values where the first value is the EXIF data label and the second is the EXIF data itself (you might think of this as a keyset). So, a particular photo’s data might look something like this:

KeyValue
Equipment Make SONY
Camera Model ILCE-7RM2
Camera Software Adobe Photoshop Lightroom Classic 8.2 (Macintosh)
Photographer Matt Harvey
Maximum Lens Aperture f/2.8
Focal Length (35mm Equiv) 44 mm
Horizontal Resolution 96 dpi
Vertical Resolution 96 dpi
Image Created2019:02:16 21:03:14
Exposure Time 1/80 sec
F-Number f/4.5
Exposure Program Normal Program
ISO Speed Rating100
Lens Aperture f/4.5
Brightness 7.2 EV
Exposure Bias 0 EV
Metering Mode Pattern
Light Source Unknown
Flash No Flash, Compulsory
Focal Length 44.00 mm
Color Space Information sRGB
Exposure Mode Auto
White Balance Auto
Scene Capture Type Standard
Contrast Normal
Saturation Normal
Sharpness Normal
Latitude N 33° 3.9174′
Longitude W 96° 58.2118′
Resolution Unit i
Exif IFD Pointer266
Compression Scheme JPEG Compression (Thumbnail)
Horizontal Resolution 72 dpi
Vertical Resolution 72 dpi
Resolution Unit i
Offset to JPEG SOI1044
Bytes of JPEG Data19487
Exif Version2.3
Image Generated2019:02:16 07:52:16
Image Digitized2019:02:16 07:52:16
Shutter Speed 1/80 sec
Focal Plane Horiz Resolution 2164 dpcm
Focal Plane Vert Resolution 2164 dpcm
Focal Plane Res Unit cm
File Source Digital Still Camera
Scene Type Directly Photographed
Digital Zoom Ratio1
GPS Info Version 2.2.0.0
Latitude Reference N
Longitude Reference W

In the context of this project, we only care about two elements of this data: Latitude and Longitude. So, to extract individual data points, we use a couple of functions to extract the coordinates and convert to decimal:

$lon = getGps($exif["GPSLongitude"], $exif['GPSLongitudeRef']);
$lat = getGps($exif["GPSLatitude"], $exif['GPSLatitudeRef']);

Which calls:

function getGps($exifCoord, $hemi) {
	$degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;
	$minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0;
	$seconds = count($exifCoord) > 2 ? gps2Num($exifCoord[2]) : 0;
	$flip = ($hemi == 'W' or $hemi == 'S') ? -1 : 1;
	return $flip * ($degrees + $minutes / 60 + $seconds / 3600);
}
function gps2Num($coordPart) {
	$parts = explode('/', $coordPart);
	if (count($parts) <= 0)
	return 0;
	if (count($parts) == 1)
	return $parts[0];
	return floatval($parts[0]) / floatval($parts[1]);
}

So we finally have a specific photo’s GPS location. Our final step is to verify that we have valid data for GPS (i.e. neither the latitude or longitude are 0, because that’s what’s returned when no GPS data is available and there could be, but shouldn’t be, photos on the site without location data). If the verification passes, we link to Google Maps with our coordinates:

if($lat <> 0 && $lon <>0){
								echo '<a href="https://www.google.com/maps/search/?api=1&query='.$lat.','.$lon.'" target ="_blank" title="Location data may be innacurate or fuzzed in certain cases">View This Photo\'s Location on Google Maps</a></br>  ';
							}

Note that we added a title element to the anchor tag for the link that states that photo data may be inaccurate or “fuzzed” for some photos. This is because some photos were tagged “after the fact” instead of using an actual GPS log or were tagged en masse with a fairly-accurate location or were tagged with a general location to preserve privacy (i.e. photos I’ve taken at home or other people’s homes).

To view any photo’s location on the site, go to the individual page for a photo and click the “View This Photo’s Location on Google Maps” link under the photo’s tags.

If you find any bugs or photos without GPS data or have any ideas for improvements, please let me know at matt@75central.com.

Downtown Plano Photo Walk

March 29, 2014  |    1 comment  |  GPS Logs Technique/Workflow

Our Meetup.Com group, Dallas Photo Walk (a great photography group and if you’re in the Dallas area, we’d love to have you join), had a scavenger hunt photo walk in Downtown Plano, Texas, this morning. For the last couple of years, I’ve been trying to log my photo explorations on my iPhone so that I can geotag my photos after importing to Lightroom. I plan on writing about this process in the next few days, but in the meantime, I thought I’d share a map of today’s walk. Perhaps in the coming weeks, I’ll share some from other adventures I’ve had in the past.

Google Earth

© 1993-2019 Matt Harvey/75Central Photography - All Rights Reserved • Contact license@75central.com for image licensing and other queries.