# Clustering cartesian coordinates associated with 1 categorical feature

I have a series of 2D coordinates X = {x, y}. Each are associated with one categorical variable W that can take 7 different values.

E.g:

coord  W
X1     3
X2     5
X3     7
X4     3
X5     2
X6     3
X7     2
...
X2000  5
...


I would like to get all the clusters that belong to a given set of my categorical variable within 2 pixels of each other. Say, for the triplet of W values (2, 5, 7), or a tuplet of all values (1,2,3,4,5,6,7), I want to have all the sets (if any) of coordinates that are within 2 pixels of each other. What would be the most appropriate methods?

Also, there are no singletons, all these coordinates have at least another nearest neighbour with a different W value. I only know how to do this to only find the sets of pairs of coordinates for 2 different W values (using pair-wise euclidian distance matrix), but to get clusters of more elements for more than 2 of my W values, I am confused about what clustering method to use (and if that actually falls in the realm of clustering at all...), as that seems rather basic and I keep reading about rather sophisticated approaches that look overkill (KNN, HDBSCAN, ...).