title: Create a grid inside a shapefile
body: <p>I am trying to crate a grid inside a shapefile, something like this. However, I am unable to generate such grid. I was wondering if anyone has an idea on how to accomplish this. </p>
  
  <p>Here is my code - </p>
  
  <pre><code>WWWL.Shape&lt;- readOGR("E:/Juan Arango", "WWL_Commerce_OK")
  WWWL.Shape
  plot(WWWL.Shape)
  proj4string(WWWL.Shape)
  
  bb &lt;- bbox(WWWL.Shape)
  cs &lt;- c(3.28084, 3.28084)*6000  # cell size 
  cc &lt;- bb[, 1] + (cs/2)  # cell offset
  cd &lt;- ceiling(diff(t(bb))/cs)  # number of cells per direction
  grd &lt;- GridTopology(cellcentre.offset=cc, cellsize=cs, cells.dim=cd)
  grd
  sp_grd &lt;- SpatialGridDataFrame(grd,
                                 data=data.frame(id=1:prod(cd)),
                                 proj4string=CRS(proj4string(WWWL.Shape)))
  plot(sp_grd)
  </code></pre>
  
  <p>Output of <code>WWL.Shape</code>  </p>
  
  <pre><code>class       : SpatialPolygonsDataFrame 
  features    : 1 
  extent      : 334367, 334498.7, 4088915, 4089057  (xmin, xmax, ymin, ymax)
  coord. ref. : +proj=utm +zone=15 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
  variables   : 1
  names       : Id 
  min values  :  0 
  max values  :  0 
  </code></pre>