1

I want to write a script that will fill field values in the attribute table the following way:

There are dots with attributes and lines I am creating. I want the script to use the field value of the dots, which a created line is snapped on and fill a field in attribute table of the line based on the values of the dot.

I want to put the referent to be the dot (so from attribute table of the dot should be taken the data) and the line to be target (to the attribute table of the line where should the data be puten).

enter image description here


I have dots that are snapped on lines. I want value from attribute field named as HP in the attribute table on every dot that is snapped to every line to copy to attribute field HPcount in the attribute table of every line. This is how it looks the real situation in QGIS.

enter code here

  • The python issue aside, this is seems to be a duplicate of Fill attribute table on feature creation based on intersection with other layer. Can you either confirm it's a duplicate, or state what exactly is different in your case? – Erik Jul 15 at 13:52
  • The DOT and the Line are on different layers. That what i want to do with a script is shown on the picture with in this answer. – Anton Jul 15 at 14:04
  • Which picture? And it is obvious, that the points are on a different layer than the lines. – Erik Jul 15 at 14:35
  • QGIs 3.8 has 'join attributes by nearest' processing algorithm. That should work for your use case. – spatialthoughts Jul 16 at 7:02
1

Try the NNJoin plugin - it will find the nearest line to your point and create a new layer with merged attributes. Not sure how it would work the other way around, especially if you have two points snapped to the same line, but it's worth a shot.

  • 1
    QGIS 3.8 has 'join attributes by nearest' processing algorithm that does what NNJoin does. – spatialthoughts Jul 16 at 8:51

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.