Mapping and Viewing Geotagged Photos in QGIS

Today’s post is inspired by Joseph Kerski, who works at ESRI doing GIS in Education. You can read his post on Using the Photos with Locations Tool in Education. It provides some very useful information for on using ESRI software (AGOL) to map and view geotagged photos. We had an interesting discussion on teaching GIS in the academia (although I am no longer in academia - I still enjoy teaching and doing trainings). You can get a free public ArcGIS Online (AGOL) account if you’d like to give it a try. If you are a student, you can look into the Learn ArcGIS Student Program (launching September 1, 2020) that gives qualified students free access to AGOL and ArcGIS Pro for a year through a membership in the Learn ArcGIS organization. I think it’s good idea to learn both ArcGIS and QGIS.

Anyway, enough on ArcGIS. I thought I would a complementary posting on mapping and viewing geotagged photos in QGIS. If you have a need to map and view your geotagged photos then this post is for you. A geotagged photo has associated geographic location added to it by a process called geotagging. The geographic information (latitude, longitude, altitude, bearing or direction, and date/time stamp, etc.) are stored in the image’s EXIF header. If you have ever taken photos with your smartphone then most likely your photos as geotagged (assuming geolocation is enabled on your phone). Geotagged photo can be mapped and viewed in QGIS.

The only requirement to this short tutorial is that you must have photos that are already geotagged. Also, if you wan to create a web map then you need to have qgis2web plugin installed. As for QGIS version, I am using QGIS 3.14 Pi.

Step 1: Import Geotagged Photos

In QGIS: Go to the Processing Toolbar panel. If you don’t see the Processing Toolbar Panel then go to Processing Menu >> Toolbar.

Fig0001.jpg

In the Processing Toolbar panel >> Vector Creation >> Double click on Import Geotagged Photos.

Fig0002.jpg

In the Import Geotagged Photos window:

  1. Input Folder: Browse to where your photos are stored

  2. Photos [optional]: Click the drop down arrow >> Save to File. Select a file format. In this example, I’m just saving as a SHP.

  3. Click Run

Fig0003.jpg

After running the tool, you should have the point file added to your map. If you open up the attribute table of the point file, you should see something similar to the table below. Note that photo field contains the file path to the photos - you use this field below in the HTML Map Tip and to “symbolize” the points later.

Fig0033.jpg

Step 2: View Photos in Popup

Open the point layer properties:

  1. Go to the Display option.

  2. For HTML Map Tip: you can just simple use the <img> HTML tag with the source to your photo.

  3. Click Ok with done

Here is my example using the photo field (from attribute table). Note if file path is local - that is on your local drive then you will need to include file:/// to indicate the photo stored locally.

Simple example: <img src="file:///[% photo %]" width="350" height="250">

Another example: description is a new field I added to my attribute (see step further down)
<table>
<tr>
<th>[% descriptio %]</th>
</tr>
<tr>
<th><img src="file:///[% photo %]" width="350" height="250"></th>
</tr>
</table>

Fig0006.jpg

To view the photos in a popup:

  1. Turn on or enable the Map Tip and

  2. Hover your mouse on a point on your map to view your photo. Note my photo also include a description at the top — which you can add by editing the attribute table (see Optional Steps below)

Fig0014.jpg

Step 3: Show Direction Photos were Taken (OPTIONAL)

If you want to show the direction in which the photos were taken, you can do that. Just use an arrow symbol and rotation based on the Direction field (that is in your attribute table).

Open up the Layer Properties:

  1. Go to Symbology

  2. Select a Simple Marker

  3. Select arrow symbol or whatever symbol you want

  4. Rotation: Click the drop down arrow >> Field Type >> Direction

  5. Click OK and you should see the arrow symbol pointing in the direction that the photo was taken

Fig0019.jpg

Here is my example. I just made copies of my geotagged photo point layer and showed it as points and arrow to indicate direction.

Fig0020.jpg

Step 3A: Symbolize Points Using the Photos (OPTIONAL)

So what if you wanted to show the point locations using the photos themselves? You can do this with the raster

Open up Layer Properties >>

  1. Go to Symbology

  2. Click on Simple Marker

  3. Symbol Layer Type: click the drop down >> Raster Image Marker

  4. Click the Data Define Override button >> Field Type >> Photo (this is field in your attribute table)

  5. Make any other changes to the size if you want (e.g. size = 30 to make thumbnail images bigger)

Fig0021.jpg

Here is what my example looks like, using the photos as raster images to symbolize my point locations.

Fig0022.jpg

Step 4: Create Web Map with Popup (OPTIONAL)

For this portion you will need to have your photos stored on the web somewhere and be accessible using a direct link (e.g. https:///www.yourwebsite.com/filename.jpg). Also you will need the QGIS2Web Plugin installed.

I’ve edited the attribute table of my geotagged photo layer to include a Description and URL fields that I’m going to use later for a quick web map. The URL and Description Fields are new fields that I’ve added to my table (which you won’t have in your table).

Edit Attribute Table to include photo uRL

  1. Toggle the Edit (pencil) button

  2. Add New Field: input field name (e.g. URL) and field type (text or string) and length (e.g. 100). I’ve also added a description field to describe my photo.

    e.g. <img src="https://www.opengislab.com/s/DiamondHeadView.JPG" width="350" height="250">

    Note: I chose to use the full <img> html tag in my URL (with widget type = text edit) as it’s easier to specify the width and height. The QGIS2Web plugin seems to only show the full photo size, which isn’t what I want. I’ve seen others use the photo field or a URL without <img> tag with widget type = Attachment and Integrated Document Viewer option as either Image or Web View with width and height set to either auto or actual values — Using these options doesn’t work for me and doesn’t produce the result I want.

  3. When done editing table, save it

  4. Don’t forget to toggle off the Edit

Fig0004.jpg

Hide Unwanted Fields in Popup

Lets say for my web map popup I only want to show the photos (i.e. URL field) and Description only. You can do this by hiding all the other fields you don’t want to display.

Open Layer Properties:

  1. Go to Attributes Form

  2. Click on a field (e.g .photo)

  3. Widget Type: Click drop down arrow >> Hidden

  4. Make sure URL field and Description both have Widget Type = Text Edit

  5. Click OK when done

Fig0024.jpg

Create Web Map Using QGIS2 Web Plugin

You must aleady have the qgis2web plugin installed to do this portion.

Go to Web Menu >> qgis2web >> Create Web Map

Fig0025.jpg

In the Export to Web Map window:

  1. Make sure your Geotagged Photo points are visible and popups are turned on. Noticed that only the URL and Description fields are visible. Also make sure you have a basemap (e.g. Stamen Toner Light). View the other tab options and make any changes you want.

  2. Select Leaflet (seems to be option that works best)

  3. Click Update Preview button to preview your map

  4. Click Export if preview looks good

Fig0026.jpg

The Export tab has an option to Export to Folder or to an FTP site. The qgis2web plugin with export web files which you can put on a web server.

Fig0035.jpg

The exported Leaflet web map (shown locally)

Fig0027.jpg

That’s it for this post on mapping and viewing geotagged photos in QGIS. I hope you find it useful, and thanks for reading as always. Until next time :).

Setup QGIS Print Layout to use Inch Instead of Millimeter

I’m in the process of migrating as much of my workflow from ArcGIS to QGIS as possible. As part of my migration, I’m creating Layout templates to make the process of map making a bit easier. One of the questions I get all the time is how to set the units used in Layout to be in inches instead of millimeter. If you’re a QGIS user, you’ll noticed that you can change the Layout page size to be in inches (e.g. 8.5x11” Letter Portrait), however, the unit for the Ruler in Layout is hard coded in QGIS to be in millimeter - this causes a lot of confusion/frustration for users since the page size and Ruler units don’t match. This is

the workflow that I use to create a print layout template in QIGS that sets the units of the Ruler and the page size to be in inches. Note, I’m using the latest version of QGIS 3.14 Pi.

1. Open QGIS. Go to Project Menu >> New Print Layout

2. Give your new print layout a name (e.g QGIS PrintLayout Inches)

The default QGIS Layout looks like this:

Fig0002.jpg

3. Change page size via Page Properties, which is sort of hidden (its not in the menus). Right click anywhere within the Layout >> Page Properties.

Change your settings on the Page Properties to whatever you want. Here I’m changing my page size to 8.5x11 inches Portrait

Note: You may get either the Unit or Orientation grayed out depending on what page size you choose. Notice in the snapshot below, when Custom is selected the Orientation field i s grayed out, and when selecting Letter the unit is grayed out. I find this weird and don’t know if this a bug or not. But to work around it I first use Custom as my page size to input the width and height and change the unit to inches. Then switch to Letter size and change my orientation to Portrait.

Notice when Custom is selected the Orientation field is grayed out, and when selecting Letter the unit is grayed out.

Notice when Custom is selected the Orientation field is grayed out, and when selecting Letter the unit is grayed out.

4. Change the units for the Guides and Grid as needed (e.g. Inches)

Fig0007.jpg

This is how my layout looks like now. Notice that even though my page size is set to 8.5x11 inches Portrait the Ruler unit is still in mm (this is the default unit in QGIS and built into the core software).

Fig0008.jpg

At this point, you can add other map elements (e.g. Logo, map title, scale bar, etc) that you want to include in your template.

5. Save the print layout as a *.qpt template file (e.g.QGIS_Layout_inhces.qpt). Go to the Layout Menu >> Save as Template

6. Open and edit the layout template (.qpt) that you just saved. Here, I’m using Notepad++ as my text editor. Find and replace “mm” to “in” the qpt file. Save the file when done editing.

Fig0010.jpg

7. Go to Layout Menu >> Layout Manager. Open your print template.

  • Under New from Template: Select Specific

  • Navigate to your print layout template (the one you just edited above in step 6).

  • Create a new layout using the specified template

Fig0011.jpg

 Now the Ruler unit and Page Size unit match. Both should be in inches.

Fig0013.jpg

8. Optional – you can add the path to your layout templates in the Layout Settings so that QGIS will know to look for your templates.

Fig0014.jpg


That’s it for this session. I hope you find it useful. Print Layout templates is a great way to standardize map making and share them with others inside or outside your company.

Thanks for reading :)