3

I am setting up a QGIS project using a Geopackage (or shapefile) concerning the areas named with some historical toponyms and writing a brief description of them.

In the attribute table I would like to include a field in the form of "tags" (such as Youtube videos or this forum), where I can insert more keywords referenced in a single field to assign a "kind" to the object and facilitate the management of data.

The question is that an element in my conceptual model can have more genres.

For example, an element can have keywords at the same time: "restaurant", "hotel", "garden".

In a field in the attribute table I am allowed to insert only one of these values.

How could I enter multiple values in a field as an alternative to a static text system "restaurant, hotel, garden"?

  • Try the "value relation" field edit widget. It has the option to select multiple values, so it might be able to do what you want. The values (ie your keywords) must be in a table that's loaded in the project as a layer. – csk Sep 25 '18 at 19:50
6

Use the "Value Relation" field widget to select multiple items from a list

1. Create a spreadsheet with two columns.

Call the first column "key." In this column, enter the values that you want saved in the attribute table. You can use your keywords, or you can assign a shorter key to each keyword. For example, I used numbers as my keys. The value "hotel" will be saved in the attribute table as 1. This allows you to store relatively long values in a more compact format. You could also use abbreviations, such as h for hotel, and g for garden. If you prefer, you can put the same value in each column.

Call the second column "value." In this column, put all of your keywords ("restaurant", "hotel", "garden" and so on).

[![enter image description here][1]][1]

Save the spreadsheet in csv format.

2. Import the csv as an attribute-only table (ie without geometry).

enter image description here

3. Set up value relation widget

Open layer properties for the historical areas layer. Open the Attributes Form tab. Select the field (in my example the field is "categories"). For Widget Type, choose "value relation." For layer, select the table you added in step 2. (in my example the table is called "book2"). For key, select the key column. For value, select the value column.

enter image description here

When you create a new point, the data entry form will now give you a checklist.

enter image description here

The attribute table will store multiple values in a single field: enter image description here

  • I think you have explained well what I meant. I try. Thank you. – AbeteBianco Sep 26 '18 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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