Layer A contains data in "Field A", Layer B also contains a field named "Field A", can I automatically transfer the data in "Field A" from Layer A to Layer B?

I used to use RefFunctions but I cannot figure out if the new overlay functions allow this type of transfer.

  • Copy based on what? On a commom id? Thus: value on Layer A, Field A of feature 1 should be copied to Layer B, Field A of feature 1? Or based on spatial relationship?
    – Babel
    Jan 5 at 11:50
  • @Babel If I could do it based on spatial relation that would be great. So, if I already have line A-B in Layer A and it has information in Field A, if I then create a new line A-B (which is exactly the same geometry) in Layer B can I copy the data from Field A in the original feature to Field A in the new feature? Jan 5 at 11:57

1 Answer 1


Based on spatial relationship

To do it based on spatial relationship, you can use one of the overlay functions, e.g. using one of the following expressions. The first two only work if the two lines are exactly the same (version 3 even considers line direction) - in many cases, even if they should be so, in fact they are not. In such cases, you might want to use the last version.

  • overlay_within('LayerA',"name_A")[0]

  • overlay_contains('LayerA',"name_A")[0]

  • overlay_equals('lineA',name)[0]: this works only if the lines have the same direction (line A to B). For a line B to A, it will return NULL

  • overlay_nearest('lineA',name)[0]: this works if lines or not completely equal: it takes the nearest line of Layer_A to the one of Layer_B

Based on common id

To copy the content of field name_A from LayerA to a field in LayerB, where you use a common id-Filed - where the value of the id from LayerA (id_A) correspods to the id value from LayerB (id_B) - use this expression:

attribute (
    get_feature_by_id (

enter image description here

  • That's excellent. Further to that, is there a way of giving 2 objects with the same geometry that are within different layers, the same automated ID number? Jan 5 at 12:03
  • Of course: see edited answer, paragraph "Based on spatial relationship"
    – Babel
    Jan 5 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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