Is there an opportunity to use subtypes and domains in QGIS (Desktop 1.8.0) like the way it is used in ArcGIS?

I am specifically interested in the possibility of dependencies between subtypes and domains: not only a range or coded values for one field is required, but corresponding values.

For example: a subtype defines valid classes of land use categories like

01 - wood
02 - grassland
03 - urbanization
04 - ...

Associated to the subtype there are several domains describing the condition/worth of each category like

wood1 - deforestation 
wood2 - conifer forest

grass1 - pasture
grass2 - hayfield
grass3 - grass
grass4 - ...

If you use a database backend that supports domains, such as Postgresql, you can set a domain on a field. However, QGIS doesn't recognize domains yet so as you create or edit features you can try to put anything into that field, there is no dropbox like in ESRI's products. If the values violate the constraint of the domain you'll get an error when you try to save your edits and the transaction won't commit.

Edit: I tested this with QGIS 1.8 and PostgreSQL 9.1.6

Edit: Eva, yes. They aren't automatic, but if you use lookup tables to store your values and descriptions you can use foreign keys in the database to maintain integrity on the backend. Then in your QGIS document bring that table into your table of contents. For your layer go to the fields tab on the property page. Use the Value Relation widget, select the lookup table as the layer, and the code and description fields and now the description will appear in a drop down when you create or edit a feature and the key will be stored in the database. This is using QGIS 2.18.

  • 1
    Thank you. I used this domain function in qgis and it worked fine. But is it also possible to deposit a relation between two attributes? e.g. when I choose "wood" for the first field (subtype in ArcGIS) the second field only accepts "deforestation" or "conifer forest" (domain for subtype "wood"). When the first attribute is "grassland" there is only "pasture", "hayfield" oder "grass" to select.
    – Mira
    Dec 11 '12 at 16:08
  • I have looked at this, but all the examples I find require you to create a new table. I have an existing table with data, that I would like to have domains for. IE: In table1 there are 3 types of data stored as Integer (1: Tree, 2: Rock, 3: Pond). With this setup the user sees the Integer, but I would like to have a Domain so the user sees the Text version. How would you set this up with Postgres and QGIS? Jun 24 '13 at 23:41
  • 1
    Create a lookup table that translates the integer value to text, join the two in a view and display the view in QGIS. When you create the view you'll have to include a field that has a unique integer value for each row otherwise QGIS won't display it. Jun 25 '13 at 15:00
  • 1
    Are there any new findings to this within the last ~5 years? Feb 7 '18 at 10:33
  • Try using a field edit widget. I believe the Value Relation and Relation Reference widgets will be most helpful for your situation. gis.stackexchange.com/questions/156039/… Note that these settings are stored in the layer style.
    – csk
    Feb 8 '18 at 19:20

In QGIS 3.xx.x you can use Attribute Forms in layer properties to set Value Maps which allow you to pick values from a dropdown menu. You can try using Value Relation, Relation Reference or create your own form using QT Designer to associate descriptive domains.

To access this functionality right-click layer -> Properties... -> Attributes Form section -> choose desired field from "Fields" -> in "Widget Type" section choose desired widget (Value Map and Uniqe Values will allow for a choosing values from a dropdown menu. Value Relation can help with setting descriptions based on Key and Value columns).

Example: enter image description here

As mentioned in the csk's comment above, these settings are stored in the layer style. To apply these settings you must save the style as a default or save it to a file and then load it for any other layers (personally, I do both for safety). To do that just click "Style" button in lower left of the properties window and select one of the options.

enter image description here

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.