I have two polyline layers in QGIS containing information on a network and I need to transfer some attributes from the second layer to the master layer. Unfortunately their geometries are not equal, meaning, the polylines in the different layers usually do not sit in the same place, mostly a few meters apart, neither are they of the same length. That is why a common spatial join does not work, as far as I found out.

My try was to build buffers "around" the polylines of the master layer and then join certain / all attributes from the second one. But here the problem is, that at the nodes between network links I, of course, get overlapping buffers an so mostly at least 2 links of the second layer lie (at least a bit) in one buffer from the master layer.

In the left picture (a) you see the initial situation: the links on the left side (pink and bright blue) are from the master layer, the links on the right (blue and green) from the second layer. The right picture (b) shows the buffers representing the links from the master layer and again the two links from the second layer. Each of the two links lies (at least with some portion) within both buffers.

a)original links b) overlapping buffers

I was not able to find out, how the algorithms of the several join functions I used, chose one of the the two possible links to reference to the buffers.

What I am looking for is a function in which I can set, that (only) the link (from second layer) with the best / biggest "coverage" within a buffer of the master layer is referenced and its attributes are transferred.

Does anybody know, how I could manage to do this?

1 Answer 1


I think this idea would help to solve the problem: create the centroids of the lines than create buffer on the centroids (big enough), and spatial join on the intersecting cricles...

  • Thanks for your answer, Tamas, but the problem is (and my example was not chosen so well) that not always I have links of a similar length, only lying a bit apart. It also occurs that the second layer has only one link where the master layer uses two links for the same stretch, or even more odd divisions.
    – Kaefes
    Jun 6, 2015 at 21:20
  • Hi, i am not sure how did you progress with your problem, but there is one thing what may can help: postgis.net/docs/ST_Buffer.html see the endcap=flat section. I know you highlighted the qgis tag, and this is postgis. But to install local spatial database, copy your dataset there, is maybe acceptable to achieve the goal ;) Qgis also can connect to postgis in read/write connection. Hope it helps.
    – Tamas Kosa
    Jun 11, 2015 at 14:36

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.