Skip to content

Commit fd0929f

Browse files
committed
add additional docstring info about coincident points
1 parent f52e6a7 commit fd0929f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

libpysal/weights/distance.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,20 @@ class KNN(W):
8383
Notes
8484
-----
8585
86-
Ties between neighbors of equal distance are arbitrarily broken.
86+
Ties between neighbors of equal distance are arbitrarily broken.
87+
88+
Further, if many points occupy the same spatial location (i.e. observations are
89+
coincident), then you may need to increase k for those observations to
90+
acquire neighbors at different spatial locations. For example, if five
91+
points are coincident, then their four nearest neighbors will all
92+
occupy the same spatial location; only the fifth nearest neighbor will
93+
result in those coincident points becoming connected to the graph as a
94+
whole.
95+
96+
Solutions to this problem include jittering the points (by adding
97+
a small random value to each observation's location) or by adding
98+
higher-k neighbors only to the coincident points, using the
99+
weights.w_sets.w_union() function.
87100
88101
See Also
89102
--------

0 commit comments

Comments
 (0)