[R-sig-Geo] chronolgy of drawing of sp.layout
Maxime Pauwels
Maxime.Pauwels at univ-lille1.fr
Fri Aug 1 17:07:47 CEST 2008
Hello,
I'm using R and the sp package for only a few days. I have already
resolved numerous basical questions but the following one resists:
I'd like to plot spatial data with attributes and to highlight a few
points on the plot corresponding to samples locations ("pop" below).
Here is my script:
library(sp)
library(lattice) # required for trellis.par.set():
trellis.par.set(sp.theme()) # sets color ramp to bpy.colors()
data <- read.table("rdataNssSS.txt", header=T)
class(data)
[1] "SpatialPointsDataFrame"
attr(,"package")
[1] "sp"
coordinates(data) <- ~gridlong+gridlat
spplot(data, c("gridr"), scales=list(draw=T),cuts=20, regions=T,
main="rvalues", xlab = "longitude (dec.)", ylab="latitude(dec.)",
key.space="right")
#samples location
coordpop <- read.table("coordpop.txt", header=T)
x <- coordpop$long
y <- coordpop$lat
pop <- SpatialPoints(list(x,y))
class(pop)
#[1] "SpatialPoints"
#attr(,"package")
#[1] "sp"
poppoints = list("sp.points", pop, pch=21, col="black", fill="black")
spplot(data, c("gridr"), scales=list(draw=T),cuts=20, regions=T,
main="rvalues", xlab = "longitude (dec.)", ylab="latitude(dec.)",
key.space="right", sp.layout=list(poppoints))
the problem is that, as explained in the sp package manual, sp.layout
item is drawn first, before the plot of point in "data". Given that pop
points are included in data, I can't see them anymore at the end of spplot.
Does anyone have a solution to reverse this?
Max
--
Maxime Pauwels
Post-Doc
Laboratoire de Génétique et Evolution des Populations Végétales
UMR CNRS 8016
Batiment SN2 Tel : +33 3 20 43 40 76
Universite de LILLE 1 Fax : +33 3 20 43 69 79
59655 Villeneuve d'Ascq Cedex email: maxime.pauwels at univ-lille1.fr
FRANCE http://www.univ-lille1.fr/gepv
«Impose ta chance, serre ton bonheur et va vers ton risque. A te
regarder, ils s’habitueront.»
René Char
More information about the R-sig-Geo
mailing list