5

I have two streetnetwork layers containing both different attributes, none of them is similar so I can´t do a simple join. Unfortunately they are not congruent, but the line objects are close to each other. I need to add the attributes of one street network to the (geometry) of the other; so all attributes of the two layers are at one layer.

I tried with a buffer and union, but the results where bad.

The best would be if all attributes go to the blue street network. The problem is for those segments (yellow box marked), where two red lines are parallel to the blue lines. Because each of the red line contains different values of the attribute I wont to join. So maybe it would be easier to put the attributes of the blue network to the red one?

enter image description here

1
  • 1
    Try the NNJoin plugin. I'm not sure how well it handles street lines like this, but it might be exactly the right tool for the job.
    – csk
    Commented Jul 31, 2019 at 19:10

2 Answers 2

3

QGIS 3.8 offers a new tool for this: Join attributes by nearest. You can find it in the toolbox. (For older versions theres the NNJoin plugin, which basically does the same, as csk already mentioned)

As joining lines can be complex (intersections, nodes and stuff like that, resulting in "incorrect" results), I suggest to go a workaround using points on lines (one per segment or line; or more, depending on your data) and perform the join on these. Once you joined the points, you can join the points to its line.

6
  • Ah okay, I still use version 3.4. I used the geometry tool -> extract nodes to create points out of the lines for both layers. than I joined the points with the NN plugin and did a spatial join of the points back to the blue line layer. There are several wrong joined attributes to the blue layer; I think its because of the huge amount of points that were created of the lines. Is there another tool instead of "extract nodes" to transform each line /segment to only one or two points?
    – polyglot
    Commented Aug 1, 2019 at 9:04
  • I would not use nodes for this in a roads network as they are used for crossings/intersections. You can try "points along lines" in GDAL vector processing toolbox to create a point in the middle of the line (use 0,5 as distance from start)
    – MrXsquared
    Commented Aug 1, 2019 at 9:48
  • 1
    great! it works! :) there´s only a little problem for those segments where two segments of the red network are parallel to one blue segment (as above in the picture, yellow box) . With the NN plugin it matches the nearest of these line attributes; but it would be better if it would match the attributes of the line with the highest value...
    – polyglot
    Commented Aug 1, 2019 at 11:28
  • or instead of the highest value; the sum of both red lines would be the most desired option.
    – polyglot
    Commented Aug 1, 2019 at 15:51
  • 1
    If the red lines share a same ID, or something that indicates they belong together, you can build sums using a virtual layer like in this answer, then join the virtual layer to its line (or point on line) and proceed like before. If there is no indicator that shows they belong together I dont see an easy chance to do this.
    – MrXsquared
    Commented Aug 1, 2019 at 17:42
2

I had to perform a similar task using three different, but related, roadway centerline datasets from multiple different providers.

What I ended up doing was to decide which layer represented the desired physical features and location. For you, it would appear that is would be the "blue" data.

Next, you use the Snap Geometries to Layer function in QGIS to snap one of the "red" datasets to the "blue" dataset.

You likely will have to experiment with snapping distance tolerance and snapping behaviors, but the defaults are fairly sane and a good starting point.

Once you get the data lined up adequately, you can do a Join Attributes by Location, while choosing the geometric predicate that gives you the best results.

It likely isn't going to be perfect (and wasn't in my case), so a fall-back to manual editing might be required.

Your Answer

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

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