Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cardinality Question: What record does NN Join choose when there are two points inside a polygon? #27

Open
taraharder opened this issue Feb 27, 2020 · 2 comments

Comments

@taraharder
Copy link

Does anyone know what record will be chosen when using NN Join in QGIS when joining a polygon layer to a point layer with one-to-many cardinality?

I am joining a point layer to a polygon layer. The points layer are well test results with dates and concentration readings. I only want the oldest test result to be joined to the polygon it falls inside of but I'm not sure how NN Join selects which point will be joined to the polygon. Please help if you know!

Capture
(Which of the two points will be joined!?)

@havatv
Copy link
Owner

havatv commented Feb 27, 2020

Hi, @taraharder!
When there are many points that have the distance 0 from the polygon (being inside it), NNJoin chooses the first one it encounters. So this approach of joining the polygon layer to the point layer is probably not very useful for your application.
You could instead consider to do it the other way around.

  1. Make sure that your polygons have a unique id.
  2. Do NNJoin with the point layer as input layer and the polygon layer as join layer.
    In the output layer you will, for each well have information about the polygon in which it resides.
  3. Use that information to do whatever you would like to do by using the polygon id attribute/field that the points have received from the polygon layer in the join to determine which polygon the point is placed in (and perhaps group the points based on the same attribute).

@taraharder
Copy link
Author

Thanks @havatv! That is what I ended up doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants