n_repr = 1000
shuffled_points = numpy.array(points)
numpy.random.shuffle(shuffled_points)
shuffled_points = shuffled_points[:n_repr]
dists, points = tree.query(shuffled_points, k=2, p=1)
avg_dists = numpy.average(dists)
print(('average distance Manhattan with nearest neighbour is:', avg_dists))
Interpolate unstructured X,Y,Z data on best grid based on nearest neighbour distance for each points