I am currently making a geotechnical database for a company as a student. One of the goals is to locate all CPT data and make it so that if someone clicks on the CPT location they get an image of (or a link to) the cpt results. The data would be in a folder together with the QGIS project which would be transferred within the company.

So, they would get a folder from me and if they open it on their pc they should be able to just run the qgis project and have acces to the hyperlinks.

What is the best method to do this?


There are several ways of getting images to pop up when clicking on features in QGIS.

The most adaptable way is by setting up layer actions through the layer properties dialogue (https://docs.qgis.org/2.2/en/docs/training_manual/create_vector_data/actions.html) where you get it to open documents using the system default - this will work for either PDF or images (or any type of file).

Several other suggestions are also made in this question regarding opening images including incorporating the image into the identify feature field popup or as html annotation: Show images related to features in QGIS?

There are also several ways to get relative file paths.

If you're using windows this question suggests you can edit your action by including ".\" before your filepath when setting up your action - so something like this: '.\' [% "PATH" %] (Set Relative Hyperlink to open windows explorer using Actions in QGIS)

In can't get this to work for me (on Mac) so instead I use either a system variable like 'project_folder' if the photos are in a folder next to the workspace or set up your own if they're remote (you can get at the variables through Project > Project Properties > Variables) You then need to include this in your action and you can do that by inserting an expression into the action, for example:

[% @project_folder || '/' || FilePath%]

In this case my photos are held in a folder within the project folder. My FilePath field in the attribute table contains 'PhotoFolder/ImageName.jpg' so '@project_folder || '/' ||' sticks the first half of the folder path on when you initiate the action.


Not the answer you're looking for? Browse other questions tagged or ask your own question.