From fd0929f09d31ad3d21219b751889f9634c1553fd Mon Sep 17 00:00:00 2001 From: ljwolf Date: Fri, 10 Dec 2021 14:01:28 +0000 Subject: [PATCH] add additional docstring info about coincident points --- libpysal/weights/distance.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libpysal/weights/distance.py b/libpysal/weights/distance.py index 25b41d690..652a5f545 100644 --- a/libpysal/weights/distance.py +++ b/libpysal/weights/distance.py @@ -83,7 +83,20 @@ class KNN(W): Notes ----- - Ties between neighbors of equal distance are arbitrarily broken. + Ties between neighbors of equal distance are arbitrarily broken. + + Further, if many points occupy the same spatial location (i.e. observations are + coincident), then you may need to increase k for those observations to + acquire neighbors at different spatial locations. For example, if five + points are coincident, then their four nearest neighbors will all + occupy the same spatial location; only the fifth nearest neighbor will + result in those coincident points becoming connected to the graph as a + whole. + + Solutions to this problem include jittering the points (by adding + a small random value to each observation's location) or by adding + higher-k neighbors only to the coincident points, using the + weights.w_sets.w_union() function. See Also --------