title: Connecting points within a matrix via lines (hopefully for a road network)
body: <p>to aid this question I provide the following image</p>
  
  <p><a href="https://i.stack.imgur.com/Xfczd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xfczd.png" alt="enter image description here"></a></p>
  
  <p>Basically this image consists of 3 pcolor plots on top of each other (for the purpose of this question the single red cell is important).</p>
  
  <p>The magenta squares are the ones which are of interest to me. In the matrix from which the magenta squares have been plotted, only the magenta coloured entries have values, and the rest are NaNs. The centre cell of the magenta squares (or part squares) all have the same value and are the smallest amongst all of the other magenta cells.</p>
  
  <p>My question is, is there any way to connect the centre cells of the magenta squares as to form some kind of interpretation of a road or bridge network? I wouldn't like every magenta square to connect to every other magenta square ideally, but is the overall task possible (of connecting points within the matrix with lines)?</p>
  
  <p>Thanks, and if you're not quite sure what I mean please ask for more info.</p>
  
  <p>EDIT: the magenta squares are randomly generated with each script run (as is the terrain layer) hence why I can't simply just plot the line against a known start and end point</p>