title: Find coordinates of grid points within polygon
body: <p>I'm trying to get the coordinates of a set of points defining a grid <em>within</em> a polygon (which I have a shapefile for). It seemed like the simplest thing to do would be to create a grid of points, and then filter those points down to only the ones within the polygon. I looked at <a href="https://gis.stackexchange.com/questions/133625/checking-if-points-fall-within-polygon-shapefile">https://gis.stackexchange.com/questions/133625/checking-if-points-fall-within-polygon-shapefile</a> and <a href="https://stackoverflow.com/questions/14777129/convert-a-shapefile-from-polygons-to-points">Convert a shapefile from polygons to points?</a>, and based on the answers there I tried this:</p>
  
  <pre><code>library(rgdal)
  city_bdry &lt;- readOGR("Boundaries - City",
                       "geo_export_32ded882-2eab-4eaa-b9da-a18889600a40")
  res &lt;- 0.01
  bb &lt;- bbox(city_bdry)
  gt &lt;- GridTopology(cellcentre.offset = bb[,1], cellsize = c(res, res), 
                     cells.dim = c(diff(bb[,1]), diff(bb[2,])) / res + 1)
  pts &lt;- SpatialPoints(gt, proj4string = CRS(proj4string(city_bdry)))
  ov &lt;- over(pts, city_bdry)
  </code></pre>
  
  <p>The result, however, doesn't include the actual coordinates of the points that overlap the polygon, so it's useless to me. How can I get that information to be included in the dataframe? Or, is there a simpler way to do what I'm trying to do?</p>
  
  <p>The shapefile I'm using can be downloaded from <a href="https://data.cityofchicago.org/Facilities-Geographic-Boundaries/Boundaries-City/ewy2-6yfk" rel="nofollow noreferrer">https://data.cityofchicago.org/Facilities-Geographic-Boundaries/Boundaries-City/ewy2-6yfk</a></p>