I can't find any documentation on how a spatial join in QGIS is working on the following situation:

An area layer is being spatially joined with a polyline layer in order to compare attributes of both layers. But there's some cases, in which multiple lines overlap an area, each with a different attribute. My question now is: Which attribute gets selected for the spatial join?

enter image description here

In the screenshot you see that situation. The yellow line is the one QGIS actually took the value of and was written into the joined table. All other crossing lines have different values and seem to be ignored. How is that?

  • Did you use "Join attributes by Location" ? Because there you can set what it should do. The default is the first object it finds.
    – Matte
    Apr 17 '16 at 16:05
  • what do you mean with the first object? I've looked into attribute table and sorted them ascending on each row, but that yellow object never was on the top.
    – Revo
    Apr 20 '16 at 7:32
  • The first one it finds in the process. In the background there are loops running for each feature and there is checked if other features are within the spatial extend that was defined in the tool. The first one within the process has nothing to do with the order in the origin table.
    – Matte
    Apr 20 '16 at 9:02
  • okay i got it! :) , is there any scientific documentation about this? I need to explain this situation in my master thesis
    – Revo
    Apr 23 '16 at 14:11

Since spatial join creates a 1 to 1 relation, the result will be one of the lines joined with the area. Not sure what the algorithm does exactly but probably the first record found will be joined.

Not sure what result you need but I would look into intersect, where the line will be cut on the edges of the areas and merging the area attributes to the lines.

  • Oh so I need to do it the other way arround?
    – Revo
    Apr 20 '16 at 7:35
  • I'm not sure what result you need but that is exactly what I would do :-) Apr 20 '16 at 7:38
  • I'm trying to evaluate OSM's street type classification quality in relation to a cadastral dataset
    – Revo
    Apr 23 '16 at 14:13

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.