[R-sig-Geo] Overlaying rasters in spplot
Oscar Perpiñan Lamigueiro
oscar.perpinan at upm.es
Tue Nov 29 09:34:14 CET 2011
Hello,
You could try the overlaying mechanism of latticeExtra with
alpha.regions as an argument for spplot:
library(latticeExtra)
layer1<-spplot(raster1,"values",
at=brks1,col.regions=pal1,colorkey=FALSE)
layer2<-spplot(raster2, "values", at=brks2,col.regions=pal2,
alpha.regions=0.5)
layer1 + layer2
Best,
Oscar.
-------------------
Oscar Perpiñán Lamigueiro
Dpto. Ingeniería Eléctrica
EUITI-UPM
http://procomun.wordpress.com
-----------------------------------------
>I am still having trouble with some raster overlays.
>My trouble now is a result of my not really understanding how layers
>and sp.layout work in the spplot function
>
>I go through a whole mess of steps to get two rasters of identical
>extent and dimension (One is a google map tile, the other my own data)
>Plotting them using the default plot() method within raster, however
>doesn't allow me to have the color palette and breaks I want, so at
>the suggestion of one of the threads on this list I have converted my
>raster objects to SpatialGridDataFrame objects.
>
>I can plot these objects and get exactly what I want using the
>following code:
> layer1<-spplot(raster1,"values",at=brks1,col.regions=pal1,colorkey=FALSE)
> layer1
> layer2<-spplot(raster2, "values", at=brks2,col.regions=pal2)
> layer2
>
>from reading the documentation on spplot() from sp package I should be
>able to use the sp.layout attribute to map the second of these layers
>with a transparency of say .5, but I have not been able to get there.
>
>I am hoping that this is enough of a syntax question that the experts
>here can help without a full worked example--my apologies if this is
>not the case.
>
>Thanks in advance,
>
>Chris
>
>Christopher S. Fowler PhD.
>206.920.1686
>http://csfowler.com
More information about the R-sig-Geo
mailing list