[R-sig-Geo] Hole attribute in Polygon lost when made into Polygons object?

MacQueen, Don macqueen1 at llnl.gov
Thu May 28 21:58:21 CEST 2015


Thanks, Roger, it does clarify.
-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 5/26/15, 10:18 PM, "Roger Bivand" <Roger.Bivand at nhh.no> wrote:

>On Wed, 27 May 2015, MacQueen, Don wrote:
>
>> I must be missing something basic
>> (either in understanding, or possibly being blind to a typo!)
>>
>> Here is the example data:
>>
>> m1 <-structure(c(2.8, 8, 8.2, 3.9, 1.6,
>>    9.2, 6.8, 3, 1.1, 4.2),
>>   .Dim = c(5L, 2L))
>>
>>
>> Pnh <- Polygon(m1, hole=FALSE)
>> Ph  <-  Polygon(m1, hole=TRUE)
>>
>> Pnhs <- Polygons(list(Pnh), ID=1)
>> Phs <- Polygons(list(Ph), ID=1)
>>
>>
>>
>> Then:
>>> Pnh at hole
>> [1] FALSE
>>> Ph at hole
>> [1] TRUE
>>
>>> Pnhs at Polygons[[1]]@hole
>> [1] FALSE
>>> Phs at Polygons[[1]]@hole
>> [1] FALSE
>>
>> It appears that the hole attribute has been lost??
>>
>
>Yes, by design. A Polygons object is like an OGC/SFS MultiPolygon or
>Polygon object, and must have at least one exterior ring (non-hole
>sp:Polygon object). If the only Polygon object in a Polygons object has
>its hole slot set to TRUE, this is treated as a misunderstanding and
>silently changed to FALSE (and ring direction reversed if need be).
>Please 
>see the note in ?"Polygons-class".
>
>Hope this clarifies,
>
>Roger
>
>>
>> sp_1.1-0
>> R 3.1.2
>>
>> Thanks
>> -Don
>>
>>
>
>-- 
>Roger Bivand
>Department of Economics, Norwegian School of Economics,
>Helleveien 30, N-5045 Bergen, Norway.
>voice: +47 55 95 93 55; fax +47 55 95 91 00
>e-mail: Roger.Bivand at nhh.no
>



More information about the R-sig-Geo mailing list