2

I have a polygon-layer with several polygons, and I have an excel-table with many detected species in some of these polygons. I want to attach all the species that belong to polygon 1 to polygon 1, and all the species that belong to polygon 2 should be attached to polygon 2. enter image description here

So first I have a shapefile with 3 different polygons, in the screenshot you see an example for the excel table, and in the end I want to have 6 polygons, every polygon with the information, which species were found there.

I have tried to attribute join the excel data to the shapefile (https://www.youtube.com/watch?v=q6yVNcpnD8I) but then only the first species belonging for example to the polygon 1 is shown in the result attribut table.

But I want all three species that were found in polygon 1. What can I do?

My next step to create a 1-n-relation enter image description here

here comes the screenshot of the solution from the toolbox "Join Attributes by Field Value"enter image description here

10
  • 1
    What you are looking for is a 1-n relation : docs.qgis.org/3.22/en/docs/user_manual/working_with_vector/…
    – J.R
    Oct 18, 2022 at 8:36
  • thanks a lot. Now I could create the 1-n-relation like visible above. All species are indicated in the formular. But how can I create a new shapefile, that contains all species in all polygons? The export of the original shapefile did not give the result I am looking for.
    – Bertram
    Oct 18, 2022 at 9:29
  • Could you expend on what are the result you are looking, in witch way all species should be contain in a polygon ?
    – J.R
    Oct 18, 2022 at 10:05
  • I want to create a shapefile with all polygons and all species, the attribute table of the shapefile should look like my example above of the excel table.
    – Bertram
    Oct 18, 2022 at 10:36
  • If the attribute table look like your exemple excel file that mean that you will have duplicate polygon, each polygon referencing one species, on top of each other is that your goal ?
    – J.R
    Oct 18, 2022 at 12:19

2 Answers 2

2

Now I found the solution: I use the tool in the toolbox: "Join Attributes by Field Value" - see the 3. screenshot above. "Wildbienen" is the shapefile - "1Artenlisten" is the excel-table I put to the QGIS-project (csv-Format), and in both I choosed the columns, that fit together. And then - very important + I choose the option "Create separate feature for each matching feature (one-to-many)". Then "run" . Then everything works, I get a new shapefile with together 146 objects (different species in 8 polygons).

1

You can create a Virtual Layer:

select a.*, b.species from polygon123 a
left join "Sheet1" b
on a."no" = b."polygon no"

Add the shapefile and excel to the map then Layer - Add Layer - A virtual layer. Change the layer- and fieldnames in the query to match your data.

Polygon 1 is duplicated three times since I have three species in the excel:

enter image description here

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.