title: Removing numpy meshgrid points outside of a Shapely polygon
body: <p>I have a 10 x 10 grid that I would like to remove points outside of a shapely Polygon:</p>
  
  <pre><code>import numpy as np
  from shapely.geometry import Polygon, Point
  from descartes import PolygonPatch
  
  gridX, gridY = np.mgrid[0.0:10.0, 0.0:10.0]
  poly = Polygon([[1,1],[1,7],[7,7],[7,1]])
  
  #plot original figure
  fig = plt.figure()
  ax = fig.add_subplot(111)
  polyp = PolygonPatch(poly)
  ax.add_patch(polyp)
  ax.scatter(gridX,gridY)
  plt.show()
  </code></pre>
  
  <p>Here is the resulting figure:
  <img src="https://i.stack.imgur.com/gtgDb.png" alt="original fig"></p>
  
  <p>And what I want the end result to look like:
  <img src="https://i.stack.imgur.com/qf2wf.png" alt="end"></p>
  
  <p>I know that I can reshape the array to a 100 x 2 array of grid points:</p>
  
  <pre><code>stacked = np.dstack([gridX,gridY])
  reshaped = stacked.reshape(100,2)
  </code></pre>
  
  <p>I can see if the point lies within the polygon easily:</p>
  
  <pre><code>for i in reshaped:
      if Point(i).within(poly):
           print True
  </code></pre>
  
  <p>But I am having trouble taking this information and modifying the original grid</p>