title: How to group elements of a numpy array with the same value in separate numpy arrays
body: <p>As usual intro, I am a tyro in python. However, I got quite a big project to code. It is a surface flow model with Cell Automata. Anyway, I also want to include building roofs in my model. Imagine you have an ascii file indicating buildings with 1s, while the rest is 0. There are just those two states. Now, I want to find all adjacent cells indicating the same building and store them (or rather the information of y,x and one more (maybe elevation),so 3 columns) in an individual building arrays. Keep in mind that buildings can have all possible forms though diagonally connected cells doesn't belong to the same building. So only northern, southern, western and eastern cells can belong to the same building.</p>
  
  <p>I did my homework and googled it but so far I couldn't find a satisfying answer.</p>
  
  <p>example:
  initial land-cover array:</p>
  
  <pre><code>([0,0,0,0,0,0,0]
   [0,0,1,0,0,0,0]
   [0,1,1,1,0,1,1]
   [0,1,0,1,0,0,1]
   [0,0,0,0,0,0,0])
  </code></pre>
  
  <p>output(I need to now the coordinates of the cells in my initial array):</p>
  
  <pre><code> building_1=([1,2],[2,1],[2,2],[2,3],[3,1],[3,3])
   building_2=([2,5],[2,6],[3,6])
  </code></pre>
  
  <p>Any help is greatly appreciated!</p>