title: How do I create a grid of patches in NetLogo
body: <p>I would like to create a patch grid, in NetLogo, at a set distance from each other. I'd like it to look something like:</p>
  
  <p><a href="https://i.stack.imgur.com/WHSKQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WHSKQ.png" alt="enter image description here"></a></p>
  
  <p>I looked at <a href="https://stackoverflow.com/questions/32213757/netlogo-creation-of-lattice-grid-resources-world-without-using-turtles">NetLogo: creation of lattice/grid resources world without using turtles?</a> but the code provided didn't work when I tried to replicate it:</p>
  
  <pre><code>ask patches with [pxcor mod Grid = 0 and pycor mod Grid = 0] [set pcolor red]
  </code></pre>
  
  <p>as "Grid" is not defined. Any help would be very much appreciated!
  UPDATE: The questions do address the same problem, however the answer to the original question was not explicit/ repeatable by other users without assistance. The answers below clarify issues from that post and provide a code that can be used by anyone as well as an explanation of that code.</p>