I have a point geometry file (GeoPackage) which I am working with in QGIS. It contains tens of thousands of records which discuss the topic 'Mineral occurrences'. Within this point file exist thousands of records of duplicate data. The duplicates are grouped by field 'Group'. I am trying to find a way to merge the duplicate records into one consolidated row using the 'Aggregate' function.

The merging of the data must adhere to set rules. Please refer to the attached image:

Where field "Data_Ver" = 'Yes', then the "Name", "X", "Y", "Data_Ver" fields should be retained from this record, and not the other records.

When I have the majority of rows state the same value in the same field, then this value should be used.

When only one cell is populated with a value and rest (majority) are Null, then this populated value should be used (not the null value)

When all records are NULL, then obviously the answer is NULL

When you have varying values between the records, then all the data needs to be captured, by having an extra column titled "XXXXX_2", "XXXX_3.." and so on, to accommodate this extra data. If the last step is too complicated, I am also open to options where you can instead concatenate the extra data into one field, with the data separated by a semi-colon.

The idea behind this exercise is to ensure no additional data is lost when merging records. Can anyone help? enter image description here

  • 1
    feels like something you would do using SQL and query engine on your geopackage. look for "St_collect" and group by condition Commented Nov 6, 2023 at 9:23
  • Seems to be the same case as here, right? gis.stackexchange.com/a/469210/88814
    – Babel
    Commented Nov 6, 2023 at 10:00
  • You had a tag for Python but have not presented a code attempt so I’ve removed it.
    – PolyGeo
    Commented Nov 6, 2023 at 11:20


Your Answer

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

Browse other questions tagged or ask your own question.