[R-sig-Geo] quadrat counting
adrian at maths.uwa.edu.au
Wed Jun 21 07:42:40 CEST 2006
Zhijie Zhang asked how to divide a region into tiles
and count the number of points from a point pattern that
fall in each tile.
In package 'spatstat', this is done using the function quadratcount().
quadratcount(cells, 3, 4)
This would divide the window contain the 'cells' point pattern
into a 3 x 4 array of tiles, count the number of points falling in each
tile, and return the counts as a table.
Alternatively if you want to specify the exact dimensions of the tiles,
use the arguments 'xbreaks' and 'ybreaks'
quadratcount(cells, xbreaks=c(0, 0.4, 0.7, 1), ybreaks=c(0, 0.5, 1))
In spatstat version 1.9-3 (to be released shortly), the return value
can also be plotted:
q <- quadratcount(cells, 3, 4)
The plot draws the tile boundaries and displays the counts as text
(numerals in each tile).
To perform a classical chi-squared test of CSR based on quadrat counts,
use the related function quadrat.test(). This has similar arguments to quadratcount()
but performs the chi-squared test as well. It can also be plotted
(in spatstat version 1.9-3), showing the tile boundaries,
the observed and expected counts, and the Pearson residuals.
quadrat.test() will also perform a chi-squared test of a non-uniform Poisson model.
More information about the R-sig-Geo