I have two polygon layers, A and B, that have the same features but totally different attributes. I want to use the attributes from layer A, but I want them to have the more accurate geometry from layer B. How can I copy the geometry from a feature in layer B and paste it onto the attributes of the same feature in layer A?
QGIS Geometry – How to Copy Geometry from One Layer to Attributes of Another
fields-attributesgeometryqgis
Best Answer
I propose two different ways.
Using processing tools: see my answer to another question. It is not difficult to adapt it to your problem, since it is about polygon overlays
A Python script to copy&paste into Python console or to run from Python editor
The script get 2 layers A, B. Replace them with the names of your layers. B is the one providing the additional attributes. The resulting features go to a new memory layer with all attributes from both layers. Then it loops over all features from A searching for features from B, that contain the centroid of the A features. If such a B is found, take the geometry from A, and attributes from A and B , and write it to memory layer AB.
The script could be used as a template for other topological related feature comparisons as well.