[R-sig-Geo] raster package

Edzer Pebesma edzer.pebesma at uni-muenster.de
Wed Sep 5 08:31:58 CEST 2012


I can run your example without problems; the problem might be somehwere
else (seen the error message, forgot the cause). Have you tried starting
R without data, e.g. as

R --vanilla

?

On 09/05/2012 08:17 AM, Tim Appelhans wrote:
> 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)
>>
>>> plot(r)
>> 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'
>>> library(raster)
>>> search()
>> [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"
>>> raster:::plot(r)
>> Erreur dans get(name, envir = asNamespace(pkg), inherits = FALSE) :
>> objet 'plot' introuvable
>>
>> Thank you for your help,
>>
>> Céline
>>
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list