Skip to content
Prev 15717 / 29559 Next

Multiple circular holes with owin function in spatastat

On 25/07/12 04:13, ASANTOS wrote:
You mean "##Circle y coordinates" here.
What on earth is the forgoing line all about?  It adds nothing to
     the issue of concern and makes your code non-reproducible.
     We don't have "a1.past.syn".
Using rbind() here makes no sense at all; actually c(circle) makes no
     sense at all either.
If your discs did not overlap you could just use owin(poly = ...) in the 
following manner:

     CIR <- vector("list",length(x))
     for(i in 1:length(x)) CIR[[i]] <- 
disc(radius=5,centre=c(x[i],y[i]))[["bdry"]][[1]]
     W <- owin(poly=CIR)

***HOWEVER*** your discs *do* overlap, so the foregoing results in an 
error and produces
no window.  So what you have to/can do is:

     CIR <- vector("list",length(x))
     for(i in 1:length(x)) CIR[[i]] <- disc(radius=5,centre=c(x[i],y[i]))
     W <- do.call(union.owin,CIR)

This takes quite a while --- order of half a minute or so on my elderly 
laptop --- and
creates a window of type "mask".

If you really want a window with polygonal boundaries you need to

     * be operating under conditions compatible with the gpclib license

     * have the gpclib package installed

     * enable gpclib by executing

             spatstat.options(gpclib=TRUE)

before executing "W <- do.call(union.owin,CIR)".  It's much quicker than 
the "mask" type
implementation, but the fly in the ointment is that cotton pickin' license!

HTH

     cheers,

         Rolf Turner