[R-sig-Geo] Error levelplot+ layer(sp.polygons() +

Oscar Perpiñán Lamigueiro oscar.perpinan at upm.es
Sat Feb 25 12:19:11 CET 2012


Byman <bymanh at gmail.com> writes:

> Could anyone please help me.
> I am plotting raster object (tasc) with 4 seasons: ("DJF","MAM", "JJA", 
> "SON") as layers. I get this raster from an Netcdf file. I would like to 
> add (overlay) the country polygons (afrc) on top of these 4 plots of 
> levelplot.  Levelplot function works quite ok but when I call this plot 
> (p) and plot with layer(sp.polygons(afr)), I get this error:
>
> Error in get(x, envir = this, inherits = inh)(this, ...) :
>    Need at least one of stat and geom
>
[...]
> sessionInfo()
> R version 2.14.1 (2011-12-22)
> Platform: i386-pc-mingw32/i386 (32-bit)
[...]
> other attached packages:
>   [1] maps_2.2-5          fts_0.7.7           ggplot2_0.8.9       
> proto_0.3-9.2       reshape_0.8.4
>   [6] plyr_1.7.1          ncdf_1.6.6          rasterVis_0.10-9    
> hexbin_1.26.0       latticeExtra_0.6-19
> [11] RColorBrewer_1.0-5  raster_1.9-67       maptools_0.8-14     
> lattice_0.20-3      sp_0.9-95
> [16] foreign_0.8-49
>
> loaded via a namespace (and not attached):
> [1] zoo_1.7-7

Hello,

Both ggplot2 and latticeExtra define a "layer" function. You have to
call library(latticeExtra) *after* library(ggplot2) to use the
latticeExtra::layer mechanism instead of ggplot2::layer.

Best.

Oscar

-- 
Oscar Perpiñán Lamigueiro
Dpto. de Ingeniería Eléctrica
EUITI-UPM

http://procomun.wordpress.com



More information about the R-sig-Geo mailing list