I'm trying to estimate an average value of distances to K nearest neighbors. I have two sets of coordinates and I'm trying to estimate the average distance from each point in one set of coordinates to the K nearest neighbors in the other set of coordinates.
The following post is instructive in how this could be done when the neighbors are from the same set of coordinates: Simple KNN for spatial data
But in my case I have two sets representing different feature types and I would like to know the average distance between each observation of one feature type with the K nearest neighbors of the other feature type.
Any suggestions?