Calculate distance between neighbors efficiently
问题 I have data geographically scattered without any kind of pattern and I need to create an image where the value of each pixel is an average of the neighbors of that pixel that are less than X meters. For this I use the library scipy.spatial to generate a KDTree with the data ( cKDTree ). Once the data structure is generated, I locate the pixel geographically and locate the geographic points that are closest. # Generate scattered data points coord_cart= [ [ feat.geometry().GetY(), feat.geometry