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

Paulo Eduardo Cardoso paulo.mailing.list at gmail.com
Mon Feb 1 23:34:21 CET 2010


Hi,
Code exemple
library(maptools)
load(file='D:\\R\\transparencia\\TransparentPolygon.Rdata')
areas <- readShapeSpatial('D:\\R\\transparencia\\Areas.shp')
pontos <- readShapeSpatial('D:\\R\\transparencia\\Points.shp')
plot(pontos,pch=19,col=pontos$point)
plot(areas,pbg="transparent",bg="red",add=TRUE)

data can be downloaded from

http://rapidshare.com/files/344532718/TransparentPolygon.Rdata.html

example image can be downloaded grom

http://rapidshare.com/files/344533300/ExampleTransparentPolygon.png.html





2010/1/31 Roger Bivand <Roger.Bivand at nhh.no>
>
> On Sun, 31 Jan 2010, Paulo Eduardo Cardoso wrote:
>
>> Roger,
>>
>> I really thank you for you comments. You are always available to explain
>> everything, and that's a fortune for forum users.
>> But I still with the same problem. I did,'t understand how to leave the
>> inner hole or the inner polygon transparent, in order to see any other layer
>> plotter at first.
>> Should I send a simple example?
>
> Please do, either code for a provided data set, or code and a link to the URL where the data set is available.
>
> Roger
>
>>
>> 2010/1/30 Roger Bivand <Roger.Bivand at nhh.no>
>>
>>> 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
>>>
>>>
>>
>
> --
> 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