1

Iin QGIS I have a layer with all found Birds in a City ('Vogeldaten'). In the attributes they are categorized in different types of breeder (free-breeding, ground-breeding, hedge-breeding, etc.). For example: Robin is Gilde_1 = "ground-breeding" and Gilde_2 = "hedge-bredding".

Now I want to create new layers based on these categories. Like there are own layers for free-breeding, ground-breeding and hedge-breeding. I know, I can select and export them. But I also want that when I make an new input in 'Vogeldaten' that this input automatically appears/is copied to the own layer based on its breeder-category. For example I have a new bird in the "ground-breeding" category in layer "Vogeldaten" it is copied automatically also in the layer "ground-breeding".

I find in QGIS in the properties the function of dependencies, but there I cannot choose/select, that only birds in the right category are copied.

Is there any Python solution or other thing?

3
  • 1
    you can solve this issue with virtual layer and a SQL query, but it's necessary to have table structure. Can you add a table as example?
    – EFiore
    Commented Aug 9, 2021 at 10:28
  • @EFiore I think that approach will only work if you predefine the set of categories. If a new feature is added in a category that doesn't exist then there's no way (in the Virtual Layer/SQL system) to make new layers on the fly. Are all the possible categories known?
    – Spacedman
    Commented Aug 9, 2021 at 12:53
  • @Spacedman you are right. My approach is to create a virtual layer for each categories. If will be introduced a new category, you will have to create a new virtual layer, for that category
    – EFiore
    Commented Aug 9, 2021 at 13:09

1 Answer 1

1

If you already know what data fields will be used to differentiate the kinds of birds, why don't you

  1. Duplicate the Vogeldaten layer (right click layer in QGIS -> Duplicate Layer)
  2. and then filter it with the Query Builder (right click layer -> Filter...), renaming and styling each layer appropriately

Duplicating doesn't create a new file, it just loads the same data source another time in the QGIS project. But each iteration can be treated like its own layer in terms of styling, filtering, etc. and still reads from one source file.


Let's say you know you have 3 categories and one data source (Vogeldaten.shp)

You can load Vogeldaten.shp as 4 layers in your QGIS project, and rename them appropriately in the QGIS project.

The first 3 would be filtered by the appropriate query (I don't know your table structure so I am making it up here) and the last is an unfiltered master that lets you see all data:

  • Vogeldaten-G (Vogeldaten.shp - Filter: "ground_breeding" = 'Y')
  • Vogeldaten-H (Vogeldaten.shp - Filter: "hedge_breeding" = 'Y')
  • Vogeldaten-F (Vogeldaten.shp - Filter: "free_breeding" = 'Y')
  • Vogeldaten-Master (Vogeldaten.shp - no filter)

Because these 4 layers are all reading from the one source file (Vogeldaten.shp) if you make a change in any one layer (e.g. add a new bird in Vogeldaten-Master or change the breeding type of a record in any of the filtered layers), it will be reflected in all the layers.

It's almost like Virtual Layers but much faster and easier.

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.