[R-sig-Geo] spplot - polygons with colored borderlines

Roger Bivand Roger.Bivand at nhh.no
Tue May 26 15:46:15 CEST 2009


On Tue, 26 May 2009, Ingo Holz wrote:

> Hi Roger,
>
> thank you for your reply. After sending my email to R-sig-Geo I recognized
> that you answered a similar question somedays ago.
>
> However, if I use col = "transparent" some of my polygons are only "colored
> dots in the space".
>
> Is there no posibility to get filled colored polygons and colored borders?

I believe that grid.polygon() as used in spplot() fills to the exact 
polygon boundary, so adding coloured boundary lines might only add a pixel 
in some places on some devices, half a point line width on vector devices. 
So if the polygons are only "dots", then that is simply their size. In 
spplot() I do not think that extracting and passing a colour vector is 
easy. It could be done with base graphics, but the plot order of the 
contiguous polygons would determine which got the extra pixels, and which 
got overpainted. I think that col="transparent" is about as much as you 
can get, really.

Roger

>
> Thank you,
> Ingo
>
>
> On Tue, 26 May 2009, Ingo Holz wrote:
>
>> Hi,
>>
>> I am using function spplot (library sp) to plot polygons:
>>
>> spplot(SPDF, "var", col.regions=topo.colors(100))
>>
>> SPDF is a SpatialPolygonsDataFrame
>>
>> Some of my polygons are very small and you can not see the color of the
>> polygon (only the black borderlines).
>>
>> I could use
>>
>> spplot(as(SPDF, "SpatialLinesDataFrame"), "variable1",
>> col.regions=topo.colors(100))
>>
>> to get colored borderlines.
>>
>> Is there a possibility to get filled colored polygons with borderlines
>> in the same color?
>
> Although it isn't obvious, you use the col= argument passed through to
> grid.polygon() used internally - see ?gpar after loading the gris package.
> You'll find that col="transparent" is OK:
>
> library(rgdal)
> scot_BNG <- readOGR(system.file("vectors", package = "rgdal")[1],
>   "scot_BNG")
> spplot(scot_BNG, "SMR")
> spplot(scot_BNG, "SMR", col="transparent")
>
> Hope this helps,
>
> Roger
>
>>
>> Thank you for your help.
>> Best wishes,
>> Ingo
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>

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