[R-sig-Geo] Problem with SpatialPolygons containing a hole

Roger Bivand Roger.Bivand at nhh.no
Thu Jan 29 14:51:31 CET 2009


On Thu, 29 Jan 2009, Hans-Jörg Bibiko wrote:

>
> On 29.01.2009, at 13:08, Roger Bivand wrote:
>
>> Set the pbg= argument to set the "bg" (background) to something other than 
>> "transparent" - if it is transparent, the previously plotted larger and 
>> encompassing polygon is still visible. I'm afraid that the documentation, 
>> which should be in ?"SpatialPolygons-class" where the plot method is 
>> described, is in the maptools package, in ?plot.polylist - this will be 
>> fixed.
>
> Thanks.
>
> plot(pseSP,col='red', pbg='white')
>
> works. But this also implies that:
> - one is not able to create a transparent hole(?)

No. By assumption, a hole is smaller than the enclosing polygon 
surrounding it. Both are "Polygon" objects in a "Polygons" object, and 
these are plotted from largest to smallest. So if a hole is transparent, 
you will see the polygon lying underneath and around it, so won't see the 
hole. "Polygon" objects are simply rings of coordinates, not topological 
structures.

> - and one has to care about the correct plotting order or to set the 
> correct pbg if that 'hole' belongs to another polygon

By assumption, "Polygon" objects that are holes should only be within 
another "Polygon" object belonging to the same "Polygons" object. It is 
possible that data in the wild do not follow this structure, though it is 
hard to think of a real case of a hole (say lake) belonging to one county, 
but lying in a different county.

Roger

>
> Cheers,
> --Hans
>
> _______________________________________________
> 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