2

I am looking for a way to implement conditional value mapping in QGIS. This means that the values available in attribute number 2 depend on the value provided in attribute 1.

Example:

If the user enters "agriculture" in attribute 1, for attribute 2 only "corn" or "wheat" will be available.

Instead, if the user enters "forest" in attribute 1, for attribute 2 only "pines" or "olives" will be available.

And so on...

Apparently this is not doable just using the QGIS widget expression builder, but I am not sure. Here's a screencast to help visualize. The problem is that if for "class" I pick other than "Agri_Field", for the "color_aggri" attribute the same possible values appear.

enter image description here

  • This is plugin/standalone application or you want to do this with standard Qgis tools (like subtypes in ArcGiS)? – dmh126 Apr 23 '15 at 11:17
  • I wish to do this with standard tools - no plugin development – Lisdengard Apr 23 '15 at 11:56
2

A similar function has been introduced recently

It requires the possible values to be grouped on the related layer and is slightly more involved in setup.

If you have a layer

Plots

  • Name
  • class (foreign key to Classes:pk)

And a layer

Classes

  • pk
  • Type [Agriculture/Forest]
  • Plant [Pines/Olives/Corn/Wheat]

You will need to add a new relation in Project Properties=>Relations that defines the foreign key from Plots:class to Classes:pk.

Then you can define a relation reference widget on Plots:class with pre-filters checked (this option is new and was introduced AFTER 2.8. Until the next release, get a nightly/master build!) and check "Type" as pre-filter.

  • Thanks Mathias! Though not exactly what I would like it (I would prefer a recursive solution), I tried it and it's definitely a valid work around! Again, thanks a lot! – Lisdengard Apr 23 '15 at 19:50
  • Can you explain what you mean with recursive? – Matthias Kuhn Apr 24 '15 at 8:02
  • Maybe not the best word, but what I meant is that it would be nice if no extra table would be needed - conditioning "on fly" attribute 2 by what was entered first in attribute 1. This something usually required for mobile GIS apps, but I think it has it's space on desktop GIS too. – Lisdengard Apr 24 '15 at 11:48
0

This issue is now easy to tackle:

http://www.itopen.it/a-new-qgis-plugin-allows-dynamic-filtering-of-values-in-forms/

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.