[R] Quadrat counting with spatstat
Petr Savicky
savicky at cs.cas.cz
Thu May 31 22:49:11 CEST 2012
On Thu, May 31, 2012 at 08:23:02AM -0700, AMFTom wrote:
> I have photographs of plots that look like so:
>
> http://r.789695.n4.nabble.com/file/n4631960/Untitled.jpg
>
> I need to divide it up so each circle has an equal area surrounding it. So
> into 20 equal segments, each of which contains a circle. Quadratcount is not
> sufficient because if I divide it up into 36 equal quadrats, some quadrats
> do not contain one of the circles.
>
> I'm not even sure how to do it mathematically, let alone using R.
Hi.
Try the following.
a <- rbind(
c(-1, -1),
c(-1, 1),
c( 1, 1),
c( 1, -1),
c(-1, -1))
plot(a, type="l")
p <- rbind(
c(0, 0),
c(-0.6, 0.6),
c(-0.6, -0.6),
c(0.6, 0.6),
c(0.6, -0.6))
points(p, col=4, pch=20, cex=4)
v <- sqrt(2/5)
b <- rbind(
c(-1, 0),
c( 0,-1),
c( 1, 0),
c( 0, 1))
for (i in 1:4) {
lines(rbind(b[i, ], v*b[i, ]))
lines(v*rbind(b[i, ], b[(i %% 4) + 1, ]))
}
This divides a square into 5 equal regions. The area of the
middle square is 2 v^2 = 4/5 and the area of each of the four
remaining parts is 1 - v^2/2 = 4/5.
If the above is repeated in a grid 2 times 2, we get a partition
of a larger square into 20 equal regions. I did not check,
whether they contain the required points, since i do not know
their exact coordinates, but they could.
Hope this helps.
Petr Savicky.
More information about the R-help
mailing list