I'm using QGIS 3.16.
I have to get coordinates from a line-layer (layer_1) and write them to a point-layer (layer_2). I cannot create the coordinates in layer_1 because i am not allowed to create any fields there.
I tried this:
attribute (get_feature ('layer_1', 'layer1_field_1', 'layer_2_field2' ), $x_at(0))
but I get 'NULL' as result, while querying the fields of layer_1 works just fine.
Am I using the attribute expression wrong? Does $x_at() not work in this context? Or should I use another expression?
Edit: I have to find a solution for several users who only have basic knowledge of GIS, this is why I am looking for a automated solution. I need x, y and z coordinates of the start- and end-vertices.
Edit 2: Usually, I would add fields to the line-layer and get the coordinates by using $x_at(0), $y_at(0), etc. and then transfer the coordinates using a variant of the code I mentioned above. That works well. In my special case, I cannot create additional fields in the line-layer and have to query the coordinates from the point-layer.
Edit3: Still trying to make my problem understandable:
This is the code I use (with adaptations to the end-position of the line-feature) to label the lines with their start- and end-coordinates without creating new fields in the respective line-layer:
Now when I try to query the same information (e.g. $x_at(0)) from a different layer or by simply using the field-calculator with the expression attribute (get_feature ('layer_1', 'layer1_field_1', 'layer_2_field2' ), $x_at(0)) mentioned above, I get NULL as a result. Is it possible to get the $x_at() expression to work this way? Or do I have to use another way altogether?
The example with the point-layer above was a (likely irritating) attempt to explain, but the solution should preferably work with the field-calculator, so it should be usable with different geometries.


