Python, Data Analytics, Geography, Photography

"Metadata liberates us, liberates knowledge."— David Weinberger
Introduction
While film Photography is making a comeback, digital photography offers many benefits. First of all, after an initial investment in a camera, lenses, storage, and accessories, there are no expenses for film or processing, unless prints are made. Also, photographers can preview images in-camera and on-site. Plus, various metadata, including the exposure and lens settings, date and time, and sometimes even GPS location, is stored in the file for each photo.
This article describes a Python program that acquires GPS coordinates and other metadata from image files and writes them to a CSV file. It will then present the metadata in a Tableau Public dashboard that tracks camera usage and image location. To introduce using Python to extract metadata from image files, see How to Use Python and Tableau to Analyze Photo Metadata.
Summary of Demonstration
Here are the tasks described in this article to process and visualize image GPS and other metadata:
- Use Adobe Lightroom or your favorite photo editor to export small image files to a folder. Ensure that the export settings include EXIF data. In my case, I selected all photos taken with the Z50, D750, and iPhone 12 in 2021. Alternatively, you can store non-edited image files that have been imported from one or more cameras in a single folder on your computer.
- Run the Python image metadata extraction program with the image file folder as its input. The program creates a CSV file that contains one metadata row per image.
- Import the CSV file that contains image metadata to Tableau Public.
- Build a Tableau dashboard that shows camera use by month and a map of photo locations.
"Photography takes an instant out of time, altering life by holding it still." – Dorothea Lange
About Image Metadata
Digital cameras store metadata about an image in a file that also contains a representation of the captured image. They hold the data in a standard format called EXIF. Here are some example fields defined within EXIF:
- Image Make – Camera make
- Image Model – Camera model
- EXIF DateTimeOriginal – The date and time when the camera captured the image
- EXIF FocalLength – The focal length of the lens
- EXIF ShutterSpeed – The shutter speed in seconds
- EXIF FNumber – The F stop
- EXIF ExposureBiasValue – The exposure bias (stops under or over the base exposure)
- EXIF WhiteBalance – The camera’s white balance setting
- EXIF ISOSpeedRating – The ISO sensor sensitivity setting
- GPS GPSLatitude – The geographic latitude in degrees, minutes, and seconds
- GPS GPSLongitude – The geographic longitude in degrees, minutes, and seconds
TsuruZoh Tachibanaya has described the EXIF file format standard. In addition, ExifTool has documented its associated GPS tags.
Python ExifRead Module
The following section presents and describes the Python program that extracts EXIF data from images. The program leverages the ExifRead module. To use the module, install it with the Python pip utility. Here is a pip use example:
$ pip install exifread
Python Program to Extract Metadata from Image Files
The program that extracts metadata from image files and stores the values in a CSV file includes two modules: a controller that serves as the program entry point and a class that reads metadata from each image file and writes it to a CSV file for later analysis and visualization. The modules are presented and described below.
photo_exif_controller.py – This file is the program’s controller module and entry point. It simply prints a start message and calls the constructor of class c_photo_exif with a set of parameters. After processing has finished, it prints the number of image files processed and a completion message.
c_photo_exif.py – The class c_photo_exif defined in this file performs these steps:
- The calling module calls the constructor (init()) with these parameters: the input image folder, the output CSV file naming, the city that the program will obtain sunrise and sunset times for, and that city’s sunset.
- The init function formats the headers of the output CSV file when it calls the init_csv_file() function. It then calls the process_photos() function, which reads each image JPEG file, one by one.
- For each image file, the process_photos() function calls the process_photo() function, which extracts a subset of the metadata from the file. The process_photo() function in turn calls the calculate_coordinate() helper function to convert the GPS degree, minute, and second values for latitude and longitude to a single value numeric decimal degree.
- Next, the process_photos() function calls write_csv_file_row() to write metadata for one image to the CSV file.
-
Finally, the controller module prints the number of image files processed and a message stating it has completed processing.
Sample Output CSV File
The screenshot below shows two metadata records for the Nikon Z 50 and iPhone 12 Pro Max cameras. If an image file contains GPS location coordinates, then the program converted latitude and longitude degree (integer), minute, and second coordinate values to decimals.

Notes About Cameras and GPS Metadata in Image Files
Even today, many DSLR and mirrorless cameras do not directly capture and store the GPS coordinates of a photo’s location in its image file. However, most, if not all, contemporary smartphones capture GPS coordinates.
In the example shown here, the Nikon D750 did not capture GPS coordinates. However, the Nikon Z50 stored GPS coordinates only when paired, in the field, with Nikon’s SnapBridge app installed on the iPhone and when the iPhone had acquired a GPS signal. On the other hand, the iPhone 12 captured the GPS coordinates whenever it had received a GPS signal.
Visualizing Camera Use and Photo Locations with Tableau Public
To analyze camera usage and photo locations, I connected Tableau Public to the photo_exif.csv file that the Python program created. Then, I built a visualization dashboard that contains two worksheets: one that tallied camera use by month, and another that showed, on a map, where I took the photos.
Tableau is a leading data visualization and business intelligence application. Its free version, Tableau Public, contains many features of the commercial software package with at least two significant limitations:
- Tableau Public can connect to a limited number of data types. For example, while it can connect to Excel and text files, it cannot link directly to a relational database as the commercial product can.
- Tableau Public saves projects only to the Tableau Public server for the whole world to see. So, if your Tableau visualizations display confidential data or don’t want to share the data with others, Tableau Public is not a good fit. Instead, you may wish to choose another visualization product, such as the commercial version of Tableau or Microsoft Power BI.
Installing Tableau Public
To install the Tableau Public desktop application on a Windows or Mac computer, navigate to https://public.tableau.com. Then, enter your email address, click on [DOWNLOAD THE APP], and follow the installation prompts.

Creating the Camera Use and Map Dashboard
The instructions listed below provide only the basic steps to build the camera use and map dashboard. To learn more about building visualization worksheets and dashboards in Tableau, see these free learning resources.
After you have learned how to use Tableau Public, follow these steps to build the dashboard:
1 – Open the Tableau Public application.
2 – In the Connect window, click on [Text file]. Then, navigate to and select the CSV file that contains the EXIF data. Finally, click [Open] to connect to the data.

3 – Review the image EXIF records in the "Data Source" window.

4 – Build a "Camera by Month" worksheet with a bar chart that shows camera use by month.

5 – Build a "Photo Map" worksheet. Add filters to apply to this worksheet and the camera use worksheet.

6 – Assemble the "Camera by Month" and "Photo Map" worksheets into a "Camera Use" dashboard.

7 – Finally, if you haven’t created a free Tableau Public account, create one now. Then, publish the dashboard to the Tableau Public website.

You can view the dashboard here.
Summary
This article demonstrated how to use Python to access the metadata about digital photos from image files. It also showed how to transform the data to prepare it for visualization and analysis. Finally, it demonstrated how to build a Tableau Public that uses the image metadata to visualize camera use and image capture locations.
Film cameras remain fantastic tools to capture images of the world around us. But by now, you might agree that digital cameras offer additional benefits to enhance the photographic process and to understand photographs and patterns.
"For me, the camera is a sketch book, an instrument of intuition and spontaneity." – Henri Cartier-Bresson