<div dir="ltr"><div><div>Hi,<br><br></div><div>More a R-Sig-Geo question but I'm sure there is connection with the rgrass7 package.<br></div>You have some errors because the argument of the image function are not the right one.<br>I think you should take a look at the help of the image.SpatialPixelsDataFrame function (?image.SpatialPixelsDataFrame)<br><br></div><div>You will see that something along these lines should work<br></div><div><br>image(year_aegypti, "repro.rate", col = topo.colors(20))<br>spplot(year_aegypti, "repro.rate")<br><br></div>A final tips when using a Spatial*DataFrame object, it's better to access directly the column like this 'year_aegypti$repro.rate' instead of <br><div>'year_aegypti@data$repro.rate'<br><br></div><div>Hope it helps<br></div><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 16, 2015 at 2:31 PM, Marisa Donnelly <span dir="ltr"><<a href="mailto:madonnelly@ucdavis.edu" target="_blank">madonnelly@ucdavis.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello, <div>I am trying to plot the image of the data from a SpatialGridDataFrame with two variables per pixel in R studio. Here is the line I am using and the error message I receive after. </div><div><br></div><div><div>> image(year_aegypti@data$repro.rate, col = topo.colors(20))</div><div>Error in image.default(year_aegypti@data$repro.rate, col = topo.colors(20)) : </div><div>  argument must be matrix-like</div><div><br></div><div>Additionally, here is the structure of the SpatialGridDataFrame I am using</div><div><br></div><div><div> str(year_aegypti)</div><div>Formal class 'SpatialGridDataFrame' [package "sp"] with 4 slots</div><div>  ..@ data       :'data.frame':<span style="white-space:pre-wrap">  </span>60950 obs. of  2 variables:</div><div>  .. ..$ year_tmean.Aegypti: num [1:60950] NA NA NA NA NA NA NA NA NA NA ...</div><div>  .. ..$ repro.rate        : num [1:60950] NA NA NA NA NA NA NA NA NA NA ...</div><div>  ..@ grid       :Formal class 'GridTopology' [package "sp"] with 3 slots</div><div>  .. .. ..@ cellcentre.offset: num [1:2] -374000 -606000</div><div>  .. .. ..@ cellsize         : num [1:2] 4000 4000</div><div>  .. .. ..@ cells.dim        : int [1:2] 230 265</div><div>  ..@ bbox       : num [1:2, 1:2] -376000 -608000 544000 452000</div><div>  .. ..- attr(*, "dimnames")=List of 2</div><div>  .. .. ..$ : NULL</div><div>  .. .. ..$ : chr [1:2] "min" "max"</div><div>  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot</div><div>  .. .. ..@ projargs: chr "+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +no_defs +a=6378137 +rf=298.257222101 +towgs84=0.000,"| __truncated__</div></div><div><br></div><div>I would like to plot only the second variable in the dataframe, $year_tmean.Aegypti, but can't quite figure out how. There are NAs in both variables, in addition to real numbers. </div><div><br></div><div>When I try spplot I get the following error:</div><div><div> spplot(year_aegypti@data$repro.rate)</div><div>Error in (function (classes, fdef, mtable)  : </div><div>  unable to find an inherited method for function ‘spplot’ for signature ‘"numeric"’</div></div><div><br></div><div>Does anyone have any ideas for solving these issues?</div><div>Thanks!</div><span class="HOEnZb"><font color="#888888"><div><div dir="ltr"><div><div><div><span style="color:rgb(153,153,153)"><span style="background-color:rgb(255,255,255)">Marisa Donnelly<br></span></span></div><span style="color:rgb(153,153,153)"><span style="background-color:rgb(255,255,255)">Ph.D. Student<br>Graduate Group in Epidemiology<br></span></span></div><span style="color:rgb(153,153,153)"><span style="background-color:rgb(255,255,255)">University of California, Davis<br></span></span></div><span style="color:rgb(153,153,153)"><a href="mailto:madonnelly@ucdavis.edu" target="_blank">madonnelly@ucdavis.edu</a></span><br></div></div>
</font></span></div></div>
<br>_______________________________________________<br>
grass-stats mailing list<br>
<a href="mailto:grass-stats@lists.osgeo.org">grass-stats@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-stats" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-stats</a><br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr">Ahmadou H. DICKO<br>statistician economist (Ingénieur Statisticien Économiste)<br>PhD candidate in Climate change economics<br>Faculty of economics and managment - Cheikh Anta Diop University<br>West African Science Service Center on Climate Change and Adaptated Land Use (WASCAL)<br>Center for Development Research (ZEF) - University of Bonn <br>email : <a href="mailto:ahmadou.dicko@ucad.edu.sn" target="_blank">ahmadou.dicko@ucad.edu.sn</a><br>twitter : @dickoah<br>github : <a href="https://github.com/dickoa" target="_blank">github/dickoa</a><br>tel : +221 33 827 55 16<br>portable: +221 77 123 81 69<br></div></div>
</div>