title: Finding a cluster with python
body: <p>I'd like to ask you to point me in a direction where I can use proper tools and functions for my problem. I have a large grid of cells (200k+) and each cell has an index and a certain value, e.g. a certain cell has <code>ID=2050</code> and <code>value=5500</code>.</p>
  
  <p>What I want to do is to find a group(s) of cells, which SUM of values matches a certain criteria, e.g. <code>SUMvalues = 15000</code> given the condition of distance between cells, which means the conditions must take into account two variables: distance between centroids and values of cells.</p>
  
  <p>Two cells next to each other can suffice the condition, but what if there are some nonadjacent cells, like on the image below?
  I am looking at the tutorials for Clustering With K-Means in Python, but i don't feel quite optimistic just yet. Do you have any other suggestions?</p>
  
  <p><a href="https://i.stack.imgur.com/PoR4F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PoR4F.png" alt="Cluster example"></a></p>
  
  <p>e</p>