I am currently digitizing an old archaeological excavation. I have created the 2m grid where finds were excavated, and have created centroids within each grid. All the corresponding finds has then been joined to the centroids and saved as a new point layer:
The point layer contains multiple points stacked upon each other, because they share the same "local coordinates" ie. 450/560.
What I want to do, is to sum the amount of "something" within between different columns.
Yellow marks "Amount" and where two points share the same coordinates
So I should like to merge all rows with the same X and Y values and have their amount summed.
I should in the end, like to end up with a new polygon layer, where each m2 contains the SUM of all the finds from that specific m2, based on different query's. So it will be possible to graduate colors based on finds intensity
Best Answer
You may use this code as a new script from Processing Toolbox (from the main QGIS Window, go to
Processing
and then click onToolbox
. From the Processing toolbox (just activated on the right side of the main QGIS window), go toCreate new script
menu under theTools
group in theScripts
algorithms block of the toolbox. Then, copy & paste my code):The result will be a new polygon memory layer which stores the same original attributes, plus one additional field containing the required sum.
If you want to change the field for the sum, slightly edit the code where it's specified (i.e. the
ft["Amount"]
line).