Hi, More a R-Sig-Geo question but I'm sure there is connection with the rgrass7 package. You have some errors because the argument of the image function are not the right one. I think you should take a look at the help of the image.SpatialPixelsDataFrame function (?image.SpatialPixelsDataFrame)
You will see that something along these lines should work image(year_aegypti, "repro.rate", col = topo.colors(20)) spplot(year_aegypti, "repro.rate") 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 'year_aegypti@data$repro.rate' Hope it helps On Wed, Sep 16, 2015 at 2:31 PM, Marisa Donnelly <madonne...@ucdavis.edu> wrote: > Hello, > 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. > > > image(year_aegypti@data$repro.rate, col = topo.colors(20)) > Error in image.default(year_aegypti@data$repro.rate, col = > topo.colors(20)) : > argument must be matrix-like > > Additionally, here is the structure of the SpatialGridDataFrame I am using > > str(year_aegypti) > Formal class 'SpatialGridDataFrame' [package "sp"] with 4 slots > ..@ data :'data.frame': 60950 obs. of 2 variables: > .. ..$ year_tmean.Aegypti: num [1:60950] NA NA NA NA NA NA NA NA NA NA > ... > .. ..$ repro.rate : num [1:60950] NA NA NA NA NA NA NA NA NA NA > ... > ..@ grid :Formal class 'GridTopology' [package "sp"] with 3 slots > .. .. ..@ cellcentre.offset: num [1:2] -374000 -606000 > .. .. ..@ cellsize : num [1:2] 4000 4000 > .. .. ..@ cells.dim : int [1:2] 230 265 > ..@ bbox : num [1:2, 1:2] -376000 -608000 544000 452000 > .. ..- attr(*, "dimnames")=List of 2 > .. .. ..$ : NULL > .. .. ..$ : chr [1:2] "min" "max" > ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot > .. .. ..@ 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__ > > 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. > > When I try spplot I get the following error: > spplot(year_aegypti@data$repro.rate) > Error in (function (classes, fdef, mtable) : > unable to find an inherited method for function ‘spplot’ for signature > ‘"numeric"’ > > Does anyone have any ideas for solving these issues? > Thanks! > Marisa Donnelly > Ph.D. Student > Graduate Group in Epidemiology > University of California, Davis > madonne...@ucdavis.edu > > _______________________________________________ > grass-stats mailing list > grass-stats@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/grass-stats > -- Ahmadou H. DICKO statistician economist (Ingénieur Statisticien Économiste) PhD candidate in Climate change economics Faculty of economics and managment - Cheikh Anta Diop University West African Science Service Center on Climate Change and Adaptated Land Use (WASCAL) Center for Development Research (ZEF) - University of Bonn email : ahmadou.di...@ucad.edu.sn twitter : @dickoah github : github/dickoa <https://github.com/dickoa> tel : +221 33 827 55 16 portable: +221 77 123 81 69
_______________________________________________ grass-stats mailing list grass-stats@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-stats