I have large single layers with many features overlapping.
Simplified example with 50% transparency:
Where the features overlap I want the attributes added together. I manually created the output I want below.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
Thanks to new Union tool in QGIS 3.2, this has become quite easy!!!
What we do, is just use Union and Aggregate tools.
(1) Union (
Processing Toolbox | Vetor Overlay | Union)
(2) We obtain
Union layer (now broken into 12 parts...sorry mostly hidden...)
(3) Aggregate (
Processing Toolbox | Vector geometry | Aggregate)
Group by expression is
geom_to_wkt( $geometry ) and the
Aggregate function is
(4) Final output is
Before QGIS 3.2
This example requires MS-Excel function, along with SAGA in QGIS Processing Toolbox.
(1) Start Polygon self-intersection tool in
QGIS Processing Toolbox | SAGA | Vector polygon tools. A trick here is to select your
value field as Identifier.
(2) This tool adds an attribute field ID which shows values of all intersected polygons, separated by a | (pipe) in between.
do not use
So, please avoid using
id for a fieldname. (The
id above is really bad example, which will be troublesome later when we save it as csv). Maybe
code would be fine.
(3) All overlapping feature will be given id: zero (0). Please edit and assign unique number. Save it as a csv file, and open by Microsoft Excel.
(4) In Excel, run
Convert Text to Columns Wizard tool. (Choose | as the separator). Calculate sum of them (eg column F as sum of C,D,E in this example).
(5) Keep columns
sum and remove all the others. Save it as new csv file.
(6) Join the new csv file with the polygon layer using
fid as the key field.
Lots of things to do... Not a pleasant way, but hope this helps.
Let's assume there is a polygon layer called 'test2' with some overlapping features in it, see the image below.
Step 1. Apply the SAGA's "Polygon Self-Intersection" tool
Note: After applying this algorithm some fields from the input original layer become meaningless. Therefore the "Drop field(s)" algorithm can be useful.
Step 2. Use a bit of the "Field Calculator" for: