3

I want to combine some columns between 2 data attribute tables.

The question, which I asked a while ago: Copying features from one attribute table to another using QGIS leads to quote long way.

Recently I "discovered" another tool, which might be far quicker. The tool is the "Merge attributes of selected features" located in the advanced toolbar.

I found some answer, which could be helpful: Copy attributes from one feature to empty row of another feature in QGIS 3, but it doesn't work in my case really.

I want to copy the XY coordinates from one attribute table to another.

enter image description here

and I was following the instructions from the thread above.

Unfortunately in my case, nothing happens. When I click OK my data attribute table remains still empty.

enter image description here

What am I doing wrong?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Geographos
  • 4,087
  • 2
  • 27
  • 88
  • Have you made sure, both columns have the same field type? Couldn't you use join attributes by field? – Erik Sep 23 '20 at 10:15
  • yes I am sure. Firstly I created the data attribute table, and next I did the centroid option from Vector section in order to gain the coordinates for my polygons. The centroid option generated the separate layer for me with the same data attribute layer. Next I could use the coordinates calculation for points, which I want now to transfer into another data attribute table – Geographos Sep 23 '20 at 10:39
  • How do these attribute tables differ, other than one has the coordinates, and the other doesn't? – Erik Sep 23 '20 at 10:45
  • Yes indeed. One attribute table has X(East) and Y(North) filled in, whereas other don't. I want to copy the data from one to another. – Geographos Sep 23 '20 at 10:46
  • And the second table is the one which belongs to the "original" polygons? – Erik Sep 23 '20 at 10:47
  • yes, the empty one – Geographos Sep 23 '20 at 10:48
  • 1
    Then I strongly suggest you make your life easier by using x(centroid($geometry)) respectively y(centroid($geometry)) on the polygon layer and forget about creating centroids and rejoining the attributes. – Erik Sep 23 '20 at 10:50
  • You are fantastic! It can be. However how it could work for Latitude and longitude? In the question here: https://gis.stackexchange.com/questions/312359/qgis-how-to-store-the-gps-coordinates-in-the-attribute-table there is an expression: x(transform($geometry, layer_property(@layer_name, 'crs'), 'EPSG:4326')) shall I use then: x(centroid(transform($geometry...)? – Geographos Sep 23 '20 at 10:53
  • Depends on which CRS your layer is in, and which CRS the coordinates should be in. If both are the same, you don't need to use transform. – Erik Sep 23 '20 at 10:58
  • 1
    Yes indeed mate! The expression: y(centroid(transform($geometry, layer_property(@layer_name, 'crs'), 'EPSG:4326'))) gives a latitude result! Many thanks for today's help! – Geographos Sep 23 '20 at 10:58
  • However the question itself still remains open as an alternative way ;) – Geographos Sep 23 '20 at 10:59
  • Keep in mind the representative point https://gis.stackexchange.com/questions/373547/creating-centroid-inside-of-polygon – Taras Sep 24 '20 at 09:41
  • Ok thanks, but I still need to know, why my "Merging attributes oof selected features" tool is not working – Geographos Sep 24 '20 at 15:32
  • Can you share your data or at least an extract of it with us? – Taras Sep 24 '20 at 19:10

0 Answers0