Sometimes you find new QGIS functionality when a user asks you a question. Somebody working with house geometries was looking for a way to copy the same attributes to a set of selected houses. He was looking if certain types of houses in a city were usable for solarpanels on the roof. And often a block of houses share off course the same properties.
After a question on the QGIS-user mailinglist the answer came: “off course this is possible…”. Here a short demonstration of this.
The secret is in the so called ‘advanced digitizing’ tools. Above a picture of both ‘digitizing’-panels. The upper row are the default tools for QGIS. The bottom row you maybe have to enable via the menu ‘View/Toolbars’.
Start with selecting the objects of which you want to share the exact same attribute values. You can select objects in QGIS in different ways: select a single feature, selecting by rectangle, polygon or freehand figures or by setting a point and select all features within a certain radius. In the image below I select for houses.
By clicking the before last the button on the advanced digitizing panel (the second white polygon with a yellow star in it) you will get the dialog you see below. In this dialog you can still remove individual features from you selection.
In our case we fill in the values we want in one of the features (e.g. the feature at the top) and the click ‘Take attributes from selected feature’. Now those values will be copied to the bottom row (merge).
After clicking OK the dialogue will close and all features will share this exact set of values. You can still see this by opening the dialogue again.
That’s it folks. In this way it is easy to assign the same set of attribute values to all houses in that block.
Using the dropdown items in te top row, it should even be possible to for example summarize the values of a column, or use the median of the values.
If you have asked yourself the question what the purpose is of the other button with exact the same image (white are plug yellow star)? That one you can use to merge the geometries of a set of features. If we use this one, we merge the 4 houses to one big one, and also giving you the chance to choose which attribute values you want to use for the new feature. You can even use the sum or median of the individual features to be used as the value of the new one.
But to be honest, very intuitive this is not working (for me). It would for example nice to have a button in the dialog to preview the (sum-, median-) action. For example in the row ‘Merge’. The dialog screendump is also showing a little painting bug for checkboxes.
But.. QGIS is a trully real open source project. So we have to start a little discussion about the GUI interaction 🙂
Leave a comment
I’m trying to do exactly that. I want to merge some selected features on a map that Im working on. I tried to use the Merge Selected Features tool but it’s gray and I cannot activate it. Any ideas?
Please let me know!
Regards!
Fernando