4

I have two polygons, after doing a dissolve I can't choose which polygon's attributes the new dissolved polygon will have. I tried to find a pattern by checking if the bigger's polygon attributes are kept but it does not appear to be the case. The selection seems random. What do you think?

The QGIS version is 3.4.11-Madeira

example

I suppose the reason it keeps the 63 is that it is higher in the attribute table as a row? Therefore it is normal that it keeps the 63?

EDIT

Here in the one layer the dissolve keeps the number that is in the higher position as a row in the attribute table which implies that prevalence is the indicator of which id it will eventually have. But the second layer that has been sorted keeps the same id as the other layer after the dissolve which means that the position in the attribute table may not be of importance in this case. enter image description here

  • 1) Do u know the attributes you want ? 2) do you know how to aggregate each of these attributes ? – snaileater Aug 26 at 15:49
  • The Merge button on the Advanced Digitizing toolbar gives you control over what happens to the attributes. – csk Aug 26 at 16:05
  • Cound you please create a new attribute within test1 and temp1 with @row_number ? – César Arquero Aug 27 at 10:22
  • I clicked "new field" in the attribute table but there is not an option to just add a number. How can I proceed? – user148382 Aug 27 at 11:26
  • @CésarArquero So what is going on?The problem is still there.Shouldn't this be considered very basic? I mean we want to dissolve two polygons and we can't figure out how to select which one's attributes to keep.Is there another way? Performing a merge, asks for layer names but these are in the same layer. – user148382 Aug 28 at 7:53
1

The dissolve tool will keep the attributes of the first geometry (by row number or index). In case you want to keep the attributes of the larger element within the group of dissolution you must to sort your shp accordingly (using the complement mmqgis for example). Here you have some screenshots of doing a dissolve befores and after a re-sort of the shp.

Shp before dissolve: enter image description here

First dissolve: enter image description here

Change shp order of elements: enter image description here

Dissolve 2: enter image description here

As you see, now data of the first element (D) is attached to the table: enter image description here

EDIT 1: I insist, the order of the element will define the attributes kept.

Here is the data:

enter image description here

Reverse sorting:

enter image description here

Dissolve 1 and dissolve 2:

enter image description here

  • Polygon with id = 32 and another with id = 45 are dissolved the final has id = 32. Later polygon with id = 32 and another with id = 3 are dissolved. The dissolved now has id = 32. How is this possible?Based on your theory it should keep the lowest id.Hence id = 3 – user148382 Aug 27 at 7:12
  • Could you share somehow your shp or some selection of features of it ? I think that may be in your data, your files "id" doesn't correspond with the order of features within the shp. – César Arquero Aug 27 at 7:25
  • I have made an edit in the question to explain what I am talking about. I think I got what you mean though. – user148382 Aug 27 at 7:40
  • What I meant is that what you see in the table of attributes don't necessarily match the internal order of features. You can try something like: sort by id, then export the shp to gpkg (it will create a new field "fid") and see if the fields "fid" and "id" are in the same order. Execute then dissolve and see if always the attributes of the first one are kept. – César Arquero Aug 27 at 7:46
  • 1
    So is my interpretation is correct???: "I suppose the reason it keeps the 63 is because it is higher in the attribute table as a row? Therefore it is normal that it keeps the 63" – user148382 Aug 27 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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