In QGIS, I have one layer (called 'All data shapefile') which is a shapefile with my entire set of data, and another layer (called 'Y_data') that is also a shape file with a subset of 'All data shapefile'. The subset was determined by making a buffer around certain key data points and extracting all data points within 100m radius of the key points to make this second layer.

In the 'All data shapefile' layer I have a column named 'ID' which gives a unique number ID for each datapoint, however I added this column after creating 'Y_data', so the latter layer does not have the ID column.

How do I append the 'ID' column into the 'Y_data' layer, ensuring that each data point will have the same ID in both layers (i.e. each data point is given its correct ID as determined by 'All data shapefile')?

When I try to use 'Join', the pictures indicate what I end up with in my 'Y_data' attribute table:

Join tool 'Y_data' attribute table

  • 1
    "Append" is usually an operation that adds rows. A join allows you to add columns
    – Vince
    Aug 22, 2021 at 19:49

1 Answer 1


Version A: Join attributes by location

Use Menu Processing / Toolbox / Join attributes by location. Settings to make (red highlighted on the screenshot):

  • Set Y_data as Base layer and All data shapefile as Join layer
  • Check the box next to intersects
  • For Join type, select Take attributes of the feature with largest overlap only (one-to-one).

Optional settings (yellow on the screenshot):

  • Fields to add (leave empty to use all fields): select the ID-field.
  • Optionally, you can set a Joined field prefix to better distinguish the initial attributes from the ones added by the join operation.

enter image description here

Version B: field calculator

You could also create a new field with field calculator on the layer Y_data and this expression:

        array_first (
  • I end up with "null" values in the column I have added when I try this Aug 22, 2021 at 19:51
  • See improved answer
    – Babel
    Aug 22, 2021 at 19:55
  • Ah, it seems I had chosen the wrong geometric predicate - choosing "equal" doesn't work, but "intersect" does. Thanks! Aug 22, 2021 at 19:58
  • 1
    Great it worked for you! I added another method, using QGIS expressions with field calculator - just in case.
    – Babel
    Aug 22, 2021 at 20:03
  • 2
    By the way: when asking questions, always add the software you use - I edited your question to add this information.
    – Babel
    Aug 22, 2021 at 20:09

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.