5

I would like to connect my taxon name column (value map) with a new column (scientific name). How to make a new scientific name autofilled when I choose a taxone name from the list?

For example: I'm choosing name from the list in the column "taxon name": Black woodpecker, and I'd like to my second column autofilled with the right scientific name: Dryocopus martius. I have both lists with names and scientific names in csv.

2
  • Should this happen right away? Otherwise you can do a join with your .CSV with both names on the column with the taxon name once you are back to the office. It's quickly done
    – Vincé
    Commented Apr 13, 2022 at 9:37
  • Please, do not forget about "What should I do when someone answers my question?"
    – Taras
    Commented May 11, 2022 at 5:00

1 Answer 1

6

Let's assume there is polygon layer called 'test2' with several features in it, see image below.

input

Step 1. Create a drop down list with values for the "TaxonName" field. Check these threads for more details: Creating drop down list with values in QGIS and Creating multiple select dropdown list in QGIS

step1

Step 2. Generate manually/programmatically a map object from your CSV or list with taxon and scientific names accordingly, e.g. map(key1,value1,key2,value2…).

map('Black woodpecker','Dryocopus martius 1','Red woodpecker','Dryocopus martius 2','White woodpecker','Dryocopus martius 3')

sorry if this example is meaningless in terms of zoology

If you prefer to work with a CSV that contains taxons, then simply drag&drop it into QGIS, see image below.

csv

Step 3. Change the default value for "Scientific" field via Layer Properties > Attributes Form > Fields > [Field] > Defaults

step3

using this expression that will contain that map object:

if("TaxonName", map_get(map('Black woodpecker','Dryocopus martius 1','Red woodpecker','Dryocopus martius 2','White woodpecker','Dryocopus martius 3'), "TaxonName"), NULL)

or another expression if referring to a CSV:

if("TaxonName", attribute(get_feature('birds', 'TaxonName', "TaxonName"), 'Scientific'), NULL)

and click Apply.

Then you achieve the desired output in the "Scientific" field after selecting the "TaxonName":

result

4
  • How to create a map object automatically? I have CSV file with almost 500 species names, it is impossible to create it maually without mistakes :(
    – Paula
    Commented Apr 13, 2022 at 11:35
  • this link doesn't work
    – Paula
    Commented Apr 13, 2022 at 11:52
  • Excellent! This looks really good. Have you tested that it works well in QField?
    – Vincé
    Commented Apr 13, 2022 at 12:16
  • IT WORKS! Thank you! I'm going to try it in QField :)
    – Paula
    Commented Apr 13, 2022 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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