Linking documents to Spatial data
Last updated
Last updated
In order to link documents to Spatial data, we need to look at Actions
We want to an an image of Rothera to our Depots file. To do that, we need to add a field to the Attribute table, add the image URL/filepath, and then create an Action to let you open the file from QGIS.
Open Layer Properties
Navigate to the Fields Tab, and toggle Editing.
Create a new Field:
Name: "image"
Type: "Text (string)"
Length: 255
Click Ok
Click "Apply"
You should now have a new table field. It will be empty, but that's where we want to add the file path to the image. We want to tell QGIS that this field contains file paths.
Navigate to the Attributes Form in the Layer Properties
Select the image
field
Set the Widget Type to Attachment
Click OK
Now, you will be able to add the file path to your table.
Open the Attribute table (right-click on the layer, and select "Attribute Table"
Scroll down to Rothera (Name = R18T in the table)
Click on the ...
symbol
Select the file you want to link to (in this case, rothera_image.jpg
)
Click Save Edits, and toggle Editing OFF (clicking the pencil symbol)
You should now have a file that contains a link to an image.
We now want to create an Action that lets users open files straight from the viewer.
Open the Actions tab for in Layer Properties
Click the +
to add a new Action. This will open an "Add New Action" dialog box. Fill in the following:
Type = Open
Toggle all the Actions Scopes on.
Click the dropdown next to "Insert"
Select "image" - this will fill in the text box with [%image%]
Toggle "Show in Attribute Table"
Ensure you select "Separate Buttons"
Now, you have an Action! Let's check if it works:
Open your layer's Attribute Table
Scroll to the Rothera row
You should see a button saying "Opens an Image"
Click it, and it opens the linked image!
This method can be used to link any kind of file in QGIS