Skip to main content
added 233 characters in body
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

First make sure your Buildings have a unique id"id" (which does not contain a | character, you will see why below). You can add it for example via field calculator by adding a new field with the expression $id if they do not have one already.

Then run "Polygon Self-Intersection"the "Polygon Self-Intersection" from SAGA Processing tools and choose this ID"id" as Identifier:

enter image description here

Which will create a new layer, where the overlapping Parts become their own polygons.

enter image description here

This new layer will contain a new ID"id" field, containing the IDs"id"s of their original buildings splittedsplit by a | sign.

Now open the field calculator of this new layer and calulatecalculate a new field with this expression:

if(regexp_match("ID",'\\|') > 0, regexp_substr("ID",'[^|]*'), "ID")

if(regexp_match("ID",'\\|') > 0,regexp_substr("ID",'[^|]*'),"ID") to get the second ID as mergeID or if(regexp_match("ID",'\\|') > 0,regexp_substr("ID",'(?<=\\|).*'),"ID") as "mergeID" or

if(regexp_match("ID",'\\|') > 0, regexp_substr("ID",'(?<=\\|).*'), "ID")

to get the first ID"ID" as mergeID"mergeID":

This expression looks up in your "ID" field, wheterwhether it contains a | character. If so, it chooses the ID before or after the | character. If it does not contain this character, it will just copy over the ID to the mergeID"mergeID".

enter image description here

Then run "Dissolve"the "Dissolve" from processing toolbox and choose this mergeID"mergeID" as dissolve field:

enter image description here

Your final result:

enter image description here

First make sure your Buildings have a unique id (which does not contain a | character, you will see why below). You can add it for example via field calculator by adding a new field with the expression $id if they do not have one already.

Then run "Polygon Self-Intersection" from SAGA Processing tools and choose this ID as Identifier:

enter image description here

Which will create a new layer, where the overlapping Parts become their own polygons.

enter image description here

This new layer will contain a new ID field, containing the IDs of their original buildings splitted by a | sign.

Now open the field calculator of this new layer and calulate a new field with this expression:

if(regexp_match("ID",'\\|') > 0,regexp_substr("ID",'[^|]*'),"ID") to get the second ID as mergeID or if(regexp_match("ID",'\\|') > 0,regexp_substr("ID",'(?<=\\|).*'),"ID") to get the first ID as mergeID:

This expression looks up in your "ID" field, wheter it contains a | character. If so, it chooses the ID before or after the | character. If it does not contain this character, it will just copy over the ID to the mergeID.

enter image description here

Then run "Dissolve" from processing toolbox and choose this mergeID as dissolve field:

enter image description here

Your final result:

enter image description here

First make sure your Buildings have a unique "id" (which does not contain a | character, you will see why below). You can add it for example via field calculator by adding a new field with the expression $id if they do not have one already.

Then run the "Polygon Self-Intersection" from SAGA Processing tools and choose this "id" as Identifier:

enter image description here

Which will create a new layer, where the overlapping Parts become their own polygons.

enter image description here

This new layer will contain a new "id" field, containing the "id"s of their original buildings split by a | sign.

Now open the field calculator of this new layer and calculate a new field with this expression:

if(regexp_match("ID",'\\|') > 0, regexp_substr("ID",'[^|]*'), "ID")

to get the second "ID" as "mergeID" or

if(regexp_match("ID",'\\|') > 0, regexp_substr("ID",'(?<=\\|).*'), "ID")

to get the first "ID" as "mergeID":

This expression looks up in your "ID" field, whether it contains a | character. If so, it chooses the ID before or after the | character. If it does not contain this character, it will just copy over the ID to the "mergeID".

enter image description here

Then run the "Dissolve" from processing toolbox and choose this "mergeID" as dissolve field:

enter image description here

Your final result:

enter image description here

Source Link
MrXsquared
  • 35.6k
  • 22
  • 71
  • 121

First make sure your Buildings have a unique id (which does not contain a | character, you will see why below). You can add it for example via field calculator by adding a new field with the expression $id if they do not have one already.

Then run "Polygon Self-Intersection" from SAGA Processing tools and choose this ID as Identifier:

enter image description here

Which will create a new layer, where the overlapping Parts become their own polygons.

enter image description here

This new layer will contain a new ID field, containing the IDs of their original buildings splitted by a | sign.

Now open the field calculator of this new layer and calulate a new field with this expression:

if(regexp_match("ID",'\\|') > 0,regexp_substr("ID",'[^|]*'),"ID") to get the second ID as mergeID or if(regexp_match("ID",'\\|') > 0,regexp_substr("ID",'(?<=\\|).*'),"ID") to get the first ID as mergeID:

This expression looks up in your "ID" field, wheter it contains a | character. If so, it chooses the ID before or after the | character. If it does not contain this character, it will just copy over the ID to the mergeID.

enter image description here

Then run "Dissolve" from processing toolbox and choose this mergeID as dissolve field:

enter image description here

Your final result:

enter image description here