[GRASS-stats] R image problem with SpatialGridDataFrame

Marisa Donnelly madonnelly at ucdavis.edu
Wed Sep 16 07:31:28 PDT 2015


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 at data$repro.rate, col = topo.colors(20))
Error in image.default(year_aegypti at 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 at 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
madonnelly at ucdavis.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-stats/attachments/20150916/aefe518d/attachment.html>


More information about the grass-stats mailing list