1

I have three points from two layers ( Point 2539 and 2538 from one layer lets say X and point AL101974 from layer Y ) ( Refer figure-1 below).

Point 2539 and 2538 has multiple attribute information ( figure-2) i wanted to add those information into point AL10974 along with distance of each point from AL10974 ( this distance we need to create not already in attribute)

I have used the Distance to nearest hub (Points) tool to get distance and other information but this will populate two columns ( when i am putting source layer as as layer X ) - fig 3 for reference.

I wanted to all these in one row so i will calculate further statistical analysis on it. Figure1 Figure2 Figure 3

0
2

You can use Menu Processing / Toolbox / Join attributes by nearest. It will create a new layer joined layer - a copy of Y, but if you set Maximum nearest neighbors to 2, you will get two duplicate features with the attributes from both points from X. You also get an attribute for the distance. You can now copy the attributes from line 2 to line 1.

To add the attribute values of feature no. 2 to feature no. 1, use Refactor fields (see documentation Refactor fields). Create new fields with the same name, but a prefix (like 2_) and this expression: attribute (get_feature_by_id (@layer,2), '[attribute_name]'), where you have to replace [attribute_name] with the name of the attribute to be copied (screenshot 2).

If you have a lot of attributes to copy, you can run Refactor fields in batch mode.

The result looks like this: Values form line 2 are copied at the end of line 1. You can now delete the second feature: enter image description here

Screenshot 2, Refactor fields dialog window: the joined attributes coming from layer X in the joined layer are copied so that the values of the 2nd feature will be copied as new attributes with the prefix 2_ to the first feature: enter image description here

5
  • Thanks Babel for suggestion. I will try this one but i am afraid as i have multiple points and due to nearest function this will calculate wrong distance from other nearest point. I Have tried oher option like Distance to nearest hub (points) and result are really messed up. Any suggestion to overcome such issue.. For each point of Y i have two points of X layers.
    – Raj
    Jul 5 at 12:52
  • It's difficult to say without seeing your data because the solution must be adapted to what you have. Can you provide your data (or a sample of it) for testing?
    – Babel
    Jul 5 at 12:56
  • @ Babel yes i can provide you .. Let me know the how to provide
    – Raj
    Jul 5 at 14:52
  • You can upload your data to some cloud service like wetransfer
    – Babel
    Jul 5 at 15:13
  • Hi Babel Please follow the below link to get sample data. I have also placed one pdf for better understanding of query. we.tl/t-oacey6PVD5
    – Raj
    Jul 5 at 18:22
0

Finally there is solution:

Using MMQGIS plugin we can create the hub distance as there is dropdown from where we can specify common field.

MMQGIS Plugin > Create > Hub distance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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