Thanks Rolf.  Your workaround seems to work in some instances, but in a
more complex one, even after verifying that no more duplicate verticies
exist, I still get the duplicate vertex error.  Strange - perhaps I'm
missing something.

Trying to track down the specific instances when this pops up, I seem to
have come across another oddity:

win1 = owin(poly=list(x=c(-1,0,2,2,0),y=c(0,-1,-1,1,1)))
U = union.owin(win1, disc(radius=1,centre=c(0,0)))
rotate(U)

    Polygon  is self-intersecting
    Error in owin(poly = bdry, unitname = unitname(X)) :
      Polygon data contain self-intersection


In the meantime, another dubious workaround is to:

rotate(as.polygonal(as.mask(union.owin(square(),disc()))))

perhaps fiddling with the pixel size beforehand.

thanks,
allie

On 1/17/2011 9:39 PM, Rolf Turner wrote:
>
> On 18/01/2011, at 9:47 AM, Alexander Shenkin wrote:
>
>> Hello Folks,
>>
>> I'm getting an error trying to rotate after union operations:
>>
>>     library(spatstat)
>>     library(gpclib)
>>     spatstat.options(gpclib=TRUE)
>>     rotate( union.owin( square(), disc() ) )
>>
>>         Polygon  contains duplicated vertices
>>         Error in owin(poly = bdry, unitname = unitname(X)) :
>>           Polygon data contain duplicated vertices
>>
>> any ideas?
>
> Well, there really are duplicated points.  The error is in the union
> operation, not in the rotate() function.  It appears to arise from the
> application of the union function in the gpclib package.  The point (0,1)
> does indeed appear twice.
>
> We'll have to ponder upon how to fix this.
>
> A somewhat dubious workaround is to do:
>
> > require(gpclib)
> > spatstat.options(gpclib=TRUE)
> > U <- union.owin(square(),disc())
> > V <- as.data.frame(U$bdry[[1]][1:2])
> > V <- V[!duplicated(V),]
> > U$bdry[[1]][1:2] <- V
> > # Check:
> > plot(rotate(U))
>
> Well, the workaround works in this toy example.  Who knows what pitfalls
> lurk in more complicated settings?
>
>     cheers,
>
>         Rolf Turner
>

	[[alternative HTML version deleted]]

