How to handle multiple matches when joining on nodes #108
luukvdmeer
started this conversation in
Debate
Replies: 1 comment
-
In v1.0, this behavior is updated. By default multiple matches will be ignored (along with a warning). However, if you set |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When doing a spatial join between the nodes of the network and an sf object, it is problematic when there are multiple matches for a single node. For example, when we join information from a set of polygons into the nodes of the network using the predicate intersects, what should happen when these polygons overlap and a node is intersecting two polygons instead of one? In
sf
this issue is solved by duplicating such a point that has multiple intersections, and attaching attributes of each intersecting polygon to one of these duplicates. This approach does not fit the network case, however. An edge can only have a single node at each of its endpoints, and thus, the duplicated nodes will be isolated an be redundant in the network structure.Currently,
sfnetworks
is throwing an error when there are multiple matches for a single node. Another option could be to always join the attribute of the first match, and additionally give a warning that multiple matches were found but only the first one is taken. This is similar to howtidygraph::unmorph()
handles it.What do you think is the better way? I tend to go for the second one.
Beta Was this translation helpful? Give feedback.
All reactions