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

Maxime Pauwels Maxime.Pauwels at univ-lille1.fr
Mon Aug 4 10:45:35 CEST 2008


Virgilio Gomez-Rubio a écrit :

Virgilio,

Many thanks for your help.
I tried a comparable solution using alpha. The result is interesting but 
the quality of the plot is markedly lower (colored pixels are apparent). 
I read on the site that panel function could be used. Unfortunately, i'm 
not familiar with such functions.

Best regards,

max


> Maxime,
>
> You can use transparencies to show the points in the layout. For
> example,
>
> library(sp)
> spp<-SpatialPoints(matrix(runif(100), ncol=2))
> sppd<-SpatialPointsDataFrame(spp, data.frame(VAL=c(rep("a", 25),
> rep("b", 25))))
>
> spplot(sppd, pch=19, col.regions=c("#11223355",  "#ff223355"),
> sp.layout=list("sp.points", spp, col.region="yellow"))
>
>
> The transparency is in the "55" bit of "#11223355" and "#ff223355".
>
> Best regards,
>
> Virgilio
>
>
> On Fri, 2008-08-01 at 17:07 +0200, 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?
>>
>> 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