1

I have a point layer which I want to spatially join to a polygon layer (bring in the attributes).

This works fine unless there are overlapping polygons, if so the QGIS spatial join tool will only bring back the features from the first one found (or some average). An average is not suitable for text attributes.

What I would prefer to happen is that if there is multiple polygons it can be joined to, it will, and result in a duplication of the point. Essentially the ArcGIS: join_operation = JOIN_ONE_TO_MANY

I am working in QGIS 2.8+.

Happy with a script/PyQGIS solution, as I don't think there are any ready made tools for it. But would prefer not to have a SpatiaLite solution as I want to keep it simple for the end user.

Ultimately if there is a solution to this problem that someone has already implemented I would love to see it. If not I will try to come up with the solution myself.

3
  • Related: gis.stackexchange.com/questions/120229 One possible workaround I can think of would be to intersect the two layers, assuming QGIS' intersect works the same as Arc. In theory each point should be duplicated once for every polygon it intersects. It will also be given the polygon IDs, so at that point you could do a regular join between the polygons and the expanded point file.
    – Chris W
    Jul 21, 2015 at 19:05
  • Hi Chris. That is a though will give that a go. Jul 23, 2015 at 9:24
  • Chris, that has worked as as specified in my question. Excellent. If you want to answer it suggesting the intersect tool I will mark it as correct. Jul 23, 2015 at 9:36

1 Answer 1

4

You are correct (at least as far as I know) that QGIS' spatial join does not offer the relationship parameter available in ArcGIS' spatial join.

In your case, since you describe a many-to-one rather than one-to-many relationship (polygons to points), there is a workaround. If you had many points you wanted to join to each polygon it wouldn't work of course, because you'd have more than one value to fill the same available slot (that would require a relate, or duplicating the polygons). But you've got multiple slots to match and only a few points, so a quick workaround is to duplicate the points - each one time for each of the polygons it touches. The Intersect tool should do this.

Once you've intersected the two layers, you should have a new set of points with at least one point for each intersecting polygon, and the points will have the ID attribute of the polygons they intersect. Points that don't intersect will be dropped of course. You should then be able to do a regular attribute/table join between the two based on the polygon ID field.

Note that if you do have multiple point matches for a single polygon, you'll have issues with this join and be back where you started - the polygon will take the first point found and none of the others. We do have some other questions for that situation.

3
  • One note, the QGIS intersect tool not only brings in the ID of the polygon, but all the attributes, so no join necessary. Jul 23, 2015 at 17:35
  • @Vesanto Well that depends. The intersect should be producing points (lowest order geometry), so if you want the polygons to have the attributes of the points, you'd have to do a join. If you want points with the polygon attributes, then you're right but I misunderstood your question and got it backward. My answer would then be a bit misleading because you actually do have a one to many (point to polygon) relationship and you'll end up with duplicate, stacked points (which may be ok for you).
    – Chris W
    Jul 23, 2015 at 17:49
  • Yes duplicate points is what I am after. Has to do with notifications for properties that fall within buffers, so some should get two notifications as the buffers are for different purposes. Jul 24, 2015 at 9:04

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.