Recently, Kurt Menke from Bird’s Eye View GIS came to Spatial Networks’ HQ office and provided us with a three-day training course on all things QGIS. While I have dabbled with QGIS in the past when attempting to assist Fulcrum users, I had never really spent a lot of time to take a deep dive into QGIS. When the opportunity arose I was eager to attend the course.
Going through the class, I thought about what I could write about that could be applicable for Fulcrum users. Originally, I planned on writing this post on creating relations between layers within QGIS as a way of showing how users could link their child data from repeatable sections back to their parent. However, I found out I was about 5 years too late as Coleman had already written about this long ago. While that post was written for QGIS 2.2 and could use a refresh, for the most part, his article is still applicable in the latest version of QGIS.
Instead, I would like to show how you can link photos to attributes within a layer and also leverage the photo EXIF data to create field-of-view (FOV) cones within QGIS 3.6.
Linking and viewing photos in QGIS
Creating a layer for photos
Working off of the same dataset that Coleman used, the parent data are the parks and the child data are the features in each of the parks. From here, we will use the photos themselves to create a new layer within QGIS. To do this:
- Open into the processing toolbox by clicking on the gear icon in the project toolbar.
- Once you have the processing toolbox open, locate the Import geotagged photos algorithm. You can use the search box at the top or locate it within the Vector Creation section.
- Within the Import Geotagged Photos window that opens, select the folder where the photos are located on your computer for the Input folder field.
- In the Photos field, you can either leave this blank and create a temporary layer or create a new layer. In this case, I have created a new layer within the GeoPackage file with the rest of the layers in this project.
- Run the process.
Linking photos to the photo layers
After the algorithm has run, you should notice a new layer with the name you set. Next we will want to link the photos to the newly created photo layer. To do this:
- Right-click on the layer and select properties.
- Select the Form icon on the right-side menu.
- Select Photo within the Fields’ drilldown.
- For the Widget Type, select Attachment.
- Select the folder where the photos are located on your computer.
- You may need to scroll down within the Widget Type section, select Image for the Type under the Integrated Document Viewer subsection.
- Optional: You can also check the Use a hyperlink for document path (read-only) option. This will add a hyperlink allowing you to open the original photo in on your computer’s photo viewer.
- Select OK to create the link.
Viewing photos from photo layers
Now that the photos are linked to the photos layer, to view the photos:
- We can highlight the photo layer by clicking on it.
- Then enable the Identify Features option on the Attributes Toolbar. Then you can select a photo point on the map to view the attributes.
- Within the Identify Results window that opens when you click on a photo point, you can select the View Form Features button to view the photos.
- Optional: Clicking on the hyperlink above the photo will open the original photo file.
Adding a FOV Cone
If you would like to take this a step further, you can also add a FOV cone to the photo pins in QGIS to see the direction that the photo was taken in. This can be helpful in seeing which way the photo was taken on the map.
Adding SVG Marker
Optionally, you can change the photo pin to a SVG marker, like a camera and also set the rotation to the direction field in the attribute table. To do this:
- Select the Layer Styling Panel icon in the layers window.
- Within the Layer Styling Panel, select the photos layer.
- Select the “Simple Marker” (SVG marker in the screenshot).
- Change Symbol layer type from Simple Marker to SVG marker.
- Locate and select the SVG icon you would like to use using the SVG Groups and SVG Image options.
- Set the Size, Fill Color, Stroke Color, and Stroke Width you would like to use.
- To set the rotation to the direction, click on the Data Define Override icon to the right of the rotation field, then within the field type dropdown select the direction field.
- Within the Layer Rendering section, it may be a good idea to set the Layer’s Blending mode to Multiply. This will allow you to see through the marker.
Creating the FOV Cone
Now that we have the pin marker set to a camera icon we can create the FOV cone. To do this:
- Select the “+” icon to create another symbol layer. Then highlight this symbol layer.
- Change Symbol layer type from Simple Marker to Geometry generator.
- Within the code box, use the function wedge_buffer($geometry, “direction”, 45, .0001, 0). You will likely need to play around with the second number (the outer radius) depending on the CRS the layer is in and your use case. I found .0001 to be pretty good for my use case in WGS 84.
- Within the Layer Rendering section, it may be a good idea to set the Layer’s Blending mode to “Multiply”.
- If you wish to get a little fancy, you can also use a “shapeburst fill” for the symbol layer type nested within the geometry generator section.
You can now pan around and view the direction that the photos are taken without having to view the attribute data directly. One thing to note is that if there is no direction data contained within the photo’s EXIF data then the camera icon will face north and there will be no FOV cone. In the screenshot below, you can see quite a few photos where the direction data was not populated by the camera/device that was used to capture the photos.
If you are interested in learning more tricks like this I would highly recommend picking up the book that Kurt used during our course called Discover QGIS 3.X. We barely scratched the surface of its contents and it is well written and easy to follow along when doing exercises on your own.
Fulcrum is a data collection platform that enables organizations to reduce costs, access critical data in real time, and improve decision making at every level. With Fulcrum, you can create custom apps using our simple drag-and-drop builder to turn your paper documents into digital forms that your field teams can quickly complete on mobile devices.