By David Crowther
How can you perform a hyperlink in QGIS to a URL, Document or Photograph?
QGIS allows you to perform several ACTIONS related to features in your GIS layers. One of those Actions is to open a URL/Hyperlink to a document or photograph stored on a server.
In this example we will use some Planning Applications in Liverpool where we will open the Planning Application document or photograph associated to each map feature.
In the attribute table we have two columns which store the filename and extension for those documents and photos – Upload1 and Upload2.
Those files are stored on a server and so by adding a static URL of – http://try.dynamicmaps.co.uk/MapThatDocs/9713/Images/- at the front of each record it will successfully open that file into a web browser window.
- http://try.dynamicmaps.co.uk/ - is the server
- MapThatDocs/ - is a virtual folder on the server as published by Internet Information Services (IIS)
- 9713/Images/ - is the folder structure under that virtual folder where the images/documents are stored
So, in the example above, the photo stored in the field Upload 2 would have a full URL reference of - http://try.dynamicmaps.co.uk/MapThatDocs/9713/Images/4261_1_prescot_housing.jpg - which would open into a browser:
For QGIS to enable this URL, we will add an ACTION that will generate the URL using the static part of the URL and then the variable which is the files name as stored in the field Upload2.
Right click on the Planning Apps Layer > choose Properties and then the ACTIONS tab.
You can add Actions 1 by 1, or simply choose Create Default Actions to get a list of default ones that you can then edit.
Remove the ACTIONS that we don’t want and keep one example of the OPEN URL Action.
The default Action will open. In this example it will open a google search, based on the variable of what the user searches for.
Edit the default action to give it a better name, choose how it is activated and update the Action Text using the static URL with the filename as stored in the column %upload2%
Save, Apply and OK and now test the Hyperlink using the ACTIONS tool from the main toolbar in the map window.
Then click on the map feature with this tool and the hyperlink will be activated.
You can create as many ACTIONS as you want, for example adding another so that it opens the PDF documents as recorded in the Upload1 field.