<div class="gmail_quote">Hello All,<br>I am trying to convert some points to a SpatialGridDataFrame and am running into difficulties.<br>When I convert the SpatialPointsDataFrame into a gridded object, it gives many warning messages <br>
and the output is incorrect. It says that the cellsize is 500x500 which is incorrect, it is actually 50,000 by 50,000)<br>
<br><font size="1"><font size="2"><span style="font-family: courier new,monospace;">my.pts &lt;- SpatialPointsDataFrame(coords=spatial.coords, data=my.df, proj4string=CRS(p4s))</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">
gridded(my.pts) &lt;- T</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

Warning messages:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

1: In points2grid(points, tolerance, round) :</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

  grid has empty column/rows in dimension 1</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

2: In points2grid(points, tolerance, round) :</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

  grid topology may be corrupt in dimension 1</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

3: In points2grid(points, tolerance, round) :</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

  grid has empty column/rows in dimension 2</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

4: In points2grid(points, tolerance, round) :</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">

  grid topology may be corrupt in dimension 2</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
str(my.pts)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
Formal class &#39;SpatialPixelsDataFrame&#39; [package &quot;sp&quot;] with 7 slots</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  ..@ data       :&#39;data.frame&#39;: 35 obs. of  2 variables:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. ..$ X1: num [1:35] 140.5 84.2 66.3 74.7 98.2 ...</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. ..$ X2: num [1:35] 155.8 73.9 57.4 72.6 88.4 ...</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  ..@ coords.nrs : num(0)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  ..@ grid       :Formal class &#39;GridTopology&#39; [package &quot;sp&quot;] with 3 slots</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. .. ..@ cellcentre.offset: Named num [1:2] -633000 -4422000</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. .. .. ..- attr(*, &quot;names&quot;)= chr [1:2] &quot;x&quot; &quot;y&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. .. ..@ cellsize         : Named num [1:2] 500 500</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. .. .. ..- attr(*, &quot;names&quot;)= chr [1:2] &quot;x&quot; &quot;y&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. .. ..@ cells.dim        : Named int [1:2] 503 902</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. .. .. ..- attr(*, &quot;names&quot;)= chr [1:2] &quot;x&quot; &quot;y&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  ..@ grid.index : int [1:35] 453405 453505 453605 453706 402904 403005 403105 403205 403305 403406 ...</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  ..@ coords     : num [1:35, 1:2] -532500 -482500 -432500 -382000 -633000 ...</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. ..- attr(*, &quot;dimnames&quot;)=List of 2</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. .. ..$ : NULL</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. .. ..$ : chr [1:2] &quot;x&quot; &quot;y&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  ..@ bbox       : num [1:2, 1:2] -633250 -4422250 -381750 -3971250</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. ..- attr(*, &quot;dimnames&quot;)=List of 2</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. .. ..$ : chr [1:2] &quot;x&quot; &quot;y&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. .. ..$ : chr [1:2] &quot;min&quot; &quot;max&quot;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  ..@ proj4string:Formal class &#39;CRS&#39; [package &quot;sp&quot;] with 1 slots</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
  .. .. ..@ projargs: chr &quot; +proj=stere +lat_0=90 +lat_ts=60
+lon_0=-110 +k=1 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m
+no_defs +towgs84=0,0,0&quot;</span></font><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"></font>



<br>I have also tried to build the GridTopology &amp; glue it together with my data:<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">gtop.coords.min &lt;- c(min(spatial.coords[,1]), min(spatial.coords[,2]))</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">gtop.coords.max &lt;- c(max(my.coords[,1]), max(my.coords[,2]))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">gtop.cell.size &lt;- c(50000, 50000)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">gtop.cells.dim.xc &lt;- length(seq(gtop.coords.min[1], gtop.coords.max[1], by=gtop.cell.size[1]))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">gtop.cells.dim.yc &lt;- length(seq(gtop.coords.min[2], gtop.coords.max[2], by=gtop.cell.size[2]))</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;"> gtop.cells.dim &lt;- c(gtop.cells.dim.xc, gtop.cells.dim.yc)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> cangrid.gtop &lt;- GridTopology(gtop.coords.min, gtop.cell.size, gtop.cells.dim)</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">str(cangrid.gtop)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Formal class &#39;GridTopology&#39; [package &quot;sp&quot;] with 3 slots</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  ..@ cellcentre.offset: num [1:2] -633000 -4422000</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  ..@ cellsize         : num [1:2] 50000 50000</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">  ..@ cells.dim        : int [1:2] 6 10</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> SpatialGridDataFrame(grid=cangrid.gtop, data=my.df, proj4string=CRS(p4s))</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">Error in validityMethod(object) :</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  unequal number of objects in full grid and data slot</span><br>

<br><br>I have included an image of what the coordinates look like and included a shapefile of the coordinates. Here is a description of my variables:<br>p4s<br>&quot;+proj=stere +lat_0=90 +lat_ts=60 +lon_0=-110 +k=1 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs&quot;<br>

<br>spatial.coords<br>         x        y<br>1  -532500 -4422000<br>2  -482500 -4422000<br>3  -432500 -4422000<br>4  -382000 -4422000<br>5  -633000 -4372000<br>6  -582500 -4372000<br>7  -532500 -4372000<br>8  -482500 -4372000<br>

9  -432500 -4372000<br>10 -382000 -4372000<br>11 -583000 -4322000<br>12 -532500 -4322000<br>13 -482500 -4322000<br>14 -432500 -4322000<br>15 -382000 -4322000<br>16 -583000 -4272000<br>17 -532500 -4272000<br>18 -482500 -4272000<br>

19 -432500 -4272000<br>20 -382000 -4272000<br>21 -583000 -4222000<br>22 -532500 -4222000<br>23 -482500 -4222000<br>24 -432500 -4222000<br>25 -583000 -4172000<br>26 -532500 -4172000<br>27 -482500 -4172000<br>28 -583000 -4122000<br>

29 -532500 -4122000<br>30 -482500 -4122000<br>31 -633000 -4071500<br>32 -583000 -4072000<br>33 -532500 -4072000<br>34 -583000 -4021500<br>35 -633000 -3971500<br><br>str(my.df)<br>&#39;data.frame&#39;:   35 obs. of  2 variables:<br>

 $ X1: num  140.5 84.2 66.3 74.7 98.2 ...<br> $ X2: num  155.8 73.9 57.4 72.6 88.4 ...<br><br>Many thanks,<br><font color="#888888">Hailey<br><br>
</font></div><br>