8

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 - ...
2

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? – Ryan Garnett 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. – HeyOverThere Jun 25 '13 at 15:00
  • 1
    Are there any new findings to this within the last ~5 years? – Eva Großmann 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

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.