[R-sig-Geo] can spplot add features ?

Roger Bivand Roger.Bivand at nhh.no
Tue Jul 7 13:05:59 CEST 2009


On Tue, 7 Jul 2009, Edzer Pebesma wrote:

>
>
> Patrick Giraudoux wrote:
>> Edzer Pebesma a écrit :
>>> Patrick Giraudoux wrote:
>>>
>>>> Dear listers,
>>>>
>>>> I would like to add the border of  a country (SpatialPolygons object
>>>> called ChinaBorder) in a spplot built as following:
>>>>
>>>> mypal<-colorRampPalette(c("white", "cyan",
>>>> "blue","green","yellow","red"))
>>>> statSpat<-SpatialPointsDataFrame(chinagrid,data.frame(n=z))
>>>> gridded(statSpat)<-TRUE
>>>> spplot(statSpat,col.regions=mypal)
>>>>
>>>> I cannot managed to overlap ChinaBorder to statSpat with the 'panel'
>>>> argument of spplot.
>>>>
>>>> Any idea about how to proceed ?
>>>>
>>> Patrick, you might want to try
>>>
>>> spplot(statSpat, col.regions = mypal, sp.layout = list("sp.polygons",
>>> ChinaBorder))
>>>
>>>> P
>>
>>
>> Exactly what I need (the way to state was unclear to me in the doc),
>> except the image is overlapping the border when I would like to get
>> the reverse (the contour over the image). Is there a way to make it ?
>>
>> Cheers,
>>
>> Patrick
>>
> Try
>
> spplot(statSpat, col.regions = mypal, sp.layout = list("sp.polygons",
> ChinaBorder, first = FALSE))
>
> or maybe TRUE.

Or even Edzer's own trick (IIRC) of turning polygons into lines:

spplot(statSpat, col.regions = mypal, sp.layout = list("sp.lines",
  as(ChinaBorder, "SpatialLines")))

with possible line width, type and colour arguments.

Roger

> --
> Edzer
>
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no


More information about the R-sig-Geo mailing list