[R-sig-Geo] chronolgy of drawing of sp.layout

Edzer Pebesma edzer.pebesma at uni-muenster.de
Mon Aug 11 15:45:25 CEST 2008



Maxime Pauwels wrote:
> 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?
Have you tried

spplot(...,
    sp.layout=list(poppoints, first=FALSE))

?
--
Edzer
>
> Max
>
>
>
>
>

-- 
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/




More information about the R-sig-Geo mailing list