Skip to content

sp.text background

3 messages · Alexandru Dumitrescu, Paul Hiemstra, Edzer Pebesma

#
There might be multiple ways of doing this. The following stays in the
realm of using spatial elements, here a rectangular polygon which is
colored white and drawn after the grid map has been drawn.

library(sp)
data(meuse.grid)
gridded(meuse.grid) = ~x+y
x = c(179500,331000)
bx = cbind(c(x[1],x[1]+300,x[1]+300,x[1],x[1]),
    c(x[2],x[2],x[2]+200,x[2]+200,x[2]))
p = SpatialPolygons(list(Polygons(list(Polygon(bx)), "ID")))
spl1 =list("sp.polygons", p, col = 0, fill='white',first=F)
spl2 =list("sp.text", x+150,"hello")
spplot(meuse.grid[3], sp.layout=list(spl1,spl2))
On 11/07/2010 09:02 AM, Alexandru Dumitrescu wrote: