[R-sig-Geo] plot polygons - transparent holes/island

Roger Bivand Roger.Bivand at nhh.no
Sat Jan 30 15:08:55 CET 2010


On Sat, 30 Jan 2010, Paulo Eduardo Cardoso wrote:

> I'd like to plot a SPDF with two objects, one of them buffering the other
> "island". How can I set the "island" transparent?
> Similarly, keeping the outer polygon only, how can the hole still
> transparent?

Polygons objects are plotted largest to smallest, as are Polygon objects 
in each Polygons object. Each Polygons object and all its constituent 
Polygon objects are painted the colour chosen for that Polygons object.

If you want the holes Polygon objects to overpaint their containing 
Polygon objects, in the base graphics plot() method, you set the pbg= 
argument to the background colour (not "transparent", this will let you 
see the painted Polygon below). In the spplot method, this is handled 
internally by reading the trellis.par.get()$background value, and using it 
if not "transparent", or "white" if it is "transparent".

Both approaches depend on the hole slot of the Polygon object being 
correctly set.

R graphics do not analyse objects leaving out say holes, they overpaint. 
This is because the holes are not "known" in advance by the functions 
being executed.

Hope this helps,

Roger

>
> Thanks in advance,
>
> Paulo E. Cardoso
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> 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