Generating a heatmap of your photos with Python

Ever wanted to have all the locations of your images plotted in a map? So that you can see where you took more photos and even which photo was taken in a specific location?

Then this is the article for you. Here I build a small python program that uses libraries such as GPSPhoto, Folium in order to create an OpenStreetMaps heatmap of your photos and also a simple popup function to see which photo it was in that location !

The resulting heatmap generated by our program for 13 images taken in Auvergne-Rhône-Alpes

And if we get closer, we can click on individual spots and get a popup of the image itself !

A popup of the image of Church of Saint George in Lyon that is shown when clicking on the individual patch of the heat map in that location.

The code is written in python 3. Create a folder named “Photos” and put the photos you want to map in it. Create a folder named “icons” as well, this is used to store the popup images with a lower size.

The script takes each .jpg image in the folder “Photos/”, creates smaller sized files in “icons/”. Takes the geo-localisation information of all images. And then generates the heatmap with the semi-transparent popup markers.

Any photos lacking GPS data are skipped. So make sure you take your photos with location turned on.

Make sure to have python3 installed.

Install the requirements using the command “pip3 install -r heatmap_requirements.txt”:

The requirements for the Python script.

And generate your heatmap in html format using the following command “python3” that executes the code below:

The code that generates the heatmap with the popups.

That’s it folks ! Enjoy discovering your past photo adventures !

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store