2

I am using QGIS 2.18, and I am looking for a way to change default values of the Merge Selected Entities algorithm.

To make it short, I have in my shape file buildings that are divided in several small parts (whereas it should not), and I would like to merge those part to get back a single building. However, one of my attributes is the height, and the default value of the merging algorithm is to pick one height among the merged entity, whereas I would like it to be always the maximum (I have quite a lot of buildings to fuse and I would like to avoid changing parameters every time I need to merge entities). Is there a way to change this through some files?

2
  • QGIS 2.18 is outdated for more than two years - in the current QGIS version, I can't find a tool named Merge Selected Entities - do you mean Merge vector layers? In any case, if your workflow anyhow includes a manual selection of features that you want to merge, you could first use the selection to create an id attribute (selected features only) and than go on as proposed by @Kazuhito.
    – Babel
    Commented Dec 26, 2020 at 11:57
  • By the way, if you use aggregate function, based on an id, you can choose in the dialog of the aggregatee tool to select the max value of your hight attribute as the valuefor the resulting (aggregated) layer
    – Babel
    Commented Dec 26, 2020 at 12:12

1 Answer 1

2

I honestly do not know how to change the way software works. Instead, I'd suggest to add a new field which represents the maximum height of each building.

QGIS 2.18 has aggregate functions and one of the functions maximum() is useful for this case.

Below is a small test example:

  • Orange building (bldg_id is 1001) and Green building (bldg_id is 1234).
  • Each of Orange and Green buildings is composed of three parts.

enter image description here

Create a new field with an expression maximum("height", group_by:= "bldg_id")

enter image description here

Then the new field (max_H in this example) will represent the tallest height of the building parts.

enter image description here

After merging, just use this newly created field (e.g. max_H here).

enter image description here

1
  • Thanks for your answer. Unfortunately, I have no such field as building_id and I know they are part of the same building by comparison with a picture. So creating a building_id field would be quite time consuming, and I don't have any other field that would allow this kind of method.
    – RClov
    Commented Nov 23, 2020 at 14:58

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.