7

I have one layer that has overlapping polygons with exact geometries. The most polygons that overlap are 5. For each polygon stack I would like to extract the values of a single field from EACH of the overlapping polygons. I don't want a summary value (mean, max, min etc), I want the actual values for every overlapping polygon. I could store these values in a shell polygon layer that had identical geometries if that helps. The dataset isn't massive (1484 features) but still too great for a manual approach.

I have searched and searched for various ways to do this. I can find ways to extract attributes from points to polygons and ways to summarise attribute values for overlapping polygons. But not to include the ACTUAL value of every overlapping polygon in an attribute table or something similar.

I have tried to union the layer with itself in QGIS. But this still results in overlapping polygons. I think it doesn't like that it has more than two overlapping polygons.

I have tried Join Attributes by Location, but this will only give me a summary value.

I have tried converting the polygons to rasters in case that path lead me down a solution. So I also have a folder with one raster for each polygon in case that might help solve things. I created these using the v.to.rast.attr and selecting the input feature class to iterate through each polygon (little green arrow next to the input feature class field). But I couldn't get my head around a raster solution either.

Here is a screen shot of the layer with transparency turned on so that you can see the overlapping polygons. The overlaps have identical geometries


Kazuhito provided a really easy solution. Here's how I ended up using it: I created the concatenated field using the expression given by Kazuhito, then deleted overlapping polygons and the other excess fields from the attribute table (no longer useful). I then saved the layer to .csv so that I could manipulate the concatenated column in excel. I extracted the comma separated into separate fields using the Data ribbon->text to columns tool. I then sorted the fields from smallest to highest value using a neat formula I found here https://www.pcmag.com/article2/0,2817,1215343,00.asp I calculated a couple of extra columns that were useful to me and then imported the table back into QGIS as a .txt file and used a join (original layer properties ->joins) to add these attributes back into the layer. I'm sure there would be a way to do the excel manipulations in the QGIS field calculator. But for me this was easy enough.

2 Answers 2

8

If you are using QGIS2.18, concatenate() function in Aggregate group may be helpful.

  1. Suppose I have a polygon layer of 5 duplicated stars (id: 1-5) and one rectangle (id:10) and each stores value I want in myvalue field.

enter image description here

  1. I open Field Calculator and create a new text field by an expression concatenate( to_string("myvalue") , group_by:= geom_to_wkt($geometry), concatenator:= ', ') to store all myvalue from the overlapping features.

enter image description here

  1. Then my new field has the same texts if the geometries are identical.

enter image description here

  1. Remove duplicates. I like MMQGIS plugin's `Delete Duplicate Geometries' but there would be various ways.

enter image description here

Done. Maybe I will delete myvalue field later.

1
  • This solved my problem very easily! Thanks for the quick response.
    – GISQ
    Commented Sep 27, 2017 at 22:14
2

What you need is spatial join. Go to Vector -> Data Management Tools -> Join attribute by location: Select your target layer where you want the attributes to show and join vector layer whose attribute you want. Also keep in mind that both the layers should have same CRS. Select your geometric predicate (which I think would be intersect). Select your attribute summary (Take attributes of the first located feature) and you are done. :)

Detailed Workflow: https://maps.cga.harvard.edu/qgis_1-7/wkshop/join_spatial.php

2

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.