Dear Celine,
I am not sure whether you can use the native graphics for plotting
raster objects. Plotting of raster objects is usually done using the
spplot() function which is built on lattice (ultimately grid) graphics.
In case you want to try if plot() also works, I think you only need two
:: when calling a package specific function. So, raster::plot(r) should
work.
Hope that helps,
Tim
On 4/9/2012 21:26, C?line Bellard wrote:
Hello,
As you see in my example, I can't use plot function from raster
library. First thing is that it seems that plot function hasn't the
priority over the plot function from graphics package. But even if I
use explicitly the plot function from raster package, it don't work.
Have you any suggestion ?
library(raster)
r=raster()
values(r)=runif(ncell(r))
r
class : RasterLayer
dimensions : 180, 360, 64800 (nrow, ncol, ncell)
resolution : 1, 1 (x, y)
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84
data source : in memory
names : layer
values : 4.09456e-06, 0.9999978 (min, max)
Erreur dans as.double(y) :
cannot coerce type 'S4' to vector of type 'double'
detach("package:raster")
plot(r)
Erreur dans as.double(y) :
cannot coerce type 'S4' to vector of type 'double'
[1] ".GlobalEnv" "package:raster" "package:sp" "tools:rstudio"
[5] "package:stats" "package:graphics" "package:grDevices"
"package:utils"
[9] "package:datasets" "package:methods" "Autoloads" "package:base"
Erreur dans get(name, envir = asNamespace(pkg), inherits = FALSE) :
objet 'plot' introuvable
Thank you for your help,
C?line