2

I have a CSV-Layer with multiple columns (e.g. ID, owner_name) and well-known text data to contain information about polygons. One ID can be owned by to owners which would cause the feature to appear twice in the attribute table. I further created a virtual field which concentrates all owners into it.

The code of the virtual field looks like this

concatenate("owner_name" ,group_by:= "ID",concatenator:=', ',order_by:= "owner_name")

This results in a attribute table as follows

ID owner_name all_owners [virtual field]
1 Simon Simon
2 Erica Erica, Peter
2 Peter Erica, Peter
3 Simon Simon

Now I want to the atlas to iterate through all unique values in the all_owners column. In this case:

  1. Simon
  2. Erica, Peter

Important: I do not want to create new (static) layers and use the dissolve function as the data in the "CSV"-Layer might get changed later on and everything shall get updated.

Note: The answer to this similar question (look here) does not work, as Virtual Layers cannot get access to virtual fields as far as I tried.

1 Answer 1

1

What I would do, is create a virtual layer that selects the distinct values of the "all_owners" column and join the geom's to that table. You could then build the atlas on that derivative virtual layer.

This is really doing in qgis with virtual layers what I would do permanently in postgres but I think would work.

I don't work a ton with virtual layers but based on my understanding, they would update automatically when the source data is updated.

This is not pulling from a csv with a virtual column but you should be able to import your csv layer and access your virtual column by name.

The query i just tested was:

enter image description here

8
  • Thanks for your answer. However I couldn't make that work: How Do select distinct values from a virtual field? The list of distinct values in the virtual layer would be enough as I can show the features of the original layer using a rule-based style pointing to the "atlas_pagename"
    – gissurfer
    Mar 23 at 15:27
  • start by just select * from my_csv_layer and check that the virtual layer was pulled through and then just switch to selecting distinct column_name Mar 23 at 15:30
  • This does not work. I get a promt: "Query preparation error on PRAGMA table_info(_tview): no such column: all_owners" I guess this happens because the virtual layer accesses the original CSV-file (which is not containing the virtual field) and not the imported CSV-layer (which contains the virtual field)
    – gissurfer
    Mar 23 at 15:37
  • are you "adding" the csv file or "importing" the layer Mar 23 at 16:57
  • 1
    Can you edit your question to include the code that creates your virtual field? I'd recommend taking this off s/o and joining then emailing [email protected]. you can join here lists.osgeo.org/mailman/listinfo/qgis-user Mar 24 at 12:24

Your Answer

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

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