I have lat lon points stored in a list, a cluster of points in a list, and a list of clusters such that:
point1 = [100,50] point2 = [100,49] point3 = [120,50] point4 = [120,49] cluster1 = [point1,point2] cluster2 = [point2,point4] clusterList = [cluster1,cluster2] I want to check to see if a point (as a list of lat lon) is in any of the clusters in the cluster lists. If it's not, I want to perform an operation.
checked = [] for cluster in clusterList: if point5 not in cluster: checked.append(1) else: checked.append(0) if all(checked): clusterList.append([point]) This solution works but it doesn't seem very elegant. I would like to know if there is a way to perform this operation either by avoiding the for loop entirely or by not having to create the object "checked" and then checking for the all() condition.
Edit
I would like to perform an operation once and only if the new point is not in any of the clusters. For clarity, I am checking to see if a point is in a cluster. If it's not, I create a new cluster for that point.