[R-sig-Geo] spatstat error, rotate after union

Rolf Turner r.turner at auckland.ac.nz
Tue Jan 18 03:39:43 CET 2011


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



More information about the R-sig-Geo mailing list