6

I've got a dataset of tiles with individual attributes (NAME,date,sensor). All tiles have the same size. After dissolving layer, in some locations tiles with the same NAME attribute overlap each other but have different sensor and date I need to merge geometry of tiles and concatenate sensor and date attribute separated with sign "/". Is there any way to do it with the QGIS field calculator and "Join attributes by location"? I have tried use "Join attributes by location" but as an output still I get overlapping shapes.

multiple overlapped tiles

Final attributes should look like: enter image description here

2

1 Answer 1

4

Use the (criminally underused) 'Aggregate' tool in the Processing Toolbox.

Group by name; set first_value as the aggregate function for the name field, and concatenate_unique for the other two fields, using / as the delimiter (if that's how you want it).


Sample data - note two distinct name values, 111 and 123

enter image description here

Processing options:

enter image description here

Result:

enter image description here


The tool will concatenate attributes based on the order of your features in your source file.

If you want the concatenated values to be in a specific order regardless of source file feature order, then you may need to either (a) use Virtual Layer to set the order of your features before concatenating, or (b) post-process the aggregated data using an expression like below in Field Calculator (may be cumbersome if you have lots of fields or need to run the aggregation multiple times).

For example to make sure the aggregated sensor field shows sensor1/sensor2 instead of sensor2/sensor1, use the expression below in Field Calculator on the aggregated layer:

array_to_string(array_sort(string_to_array("sensor",'/')),'/')
5
  • 2
    Happy to see you back with your marvelous answers :)
    – Taras
    Oct 4, 2021 at 7:53
  • 1
    Haha, thanks. I've had to take a break after spending a bit too much time here instead of doing my actual job...
    – she_weeds
    Oct 4, 2021 at 10:54
  • Can fully understand you :)
    – Taras
    Oct 5, 2021 at 4:59
  • You have made great job. Thank you for help :)
    – Piotr
    Oct 5, 2021 at 5:55
  • 1
    If the answer has helped you don't forget to mark it as accepted so that others will find it easier to get to this solution.
    – she_weeds
    Oct 5, 2021 at 6:21

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.