[R-sig-Geo] silly question on quadratcount in spatstat ?
Anna Marburg
marburga at landcareresearch.co.nz
Fri Aug 21 05:39:40 CEST 2009
Dear Alexandre -
Apologies if your question has been answered already, I read r-sig-geo
as a daily digest.
I'm not sure what is "obviously' wrong with the humberside example.
Because the observation window is an irregular polygon the quadrats on
the edge have an irregular shape. Their counts are displayed at the
center of the largest circle that can be inscribed within them.
Depending on your particular aims, you may wish to exclude quadrats
that are not completely within the owin. But it's also possible that
you want to retain all the quadrats. Perhaps a large number of your
observations are near the edge of the study area (e.g. cities along a
coastline).
If you do wish to exclude incomplete quadrats, here's some very
(very!) crude code that will extract the size of each quadrat as well
as the coordinates quadratcount() uses for it's default labeling.
library(spatstat)
data(humberside)
plot(humberside)
Q <- quadratcount(humberside, 5, 5)
tmp <- attr(Q,"tess") # pull out the definition of the quadrat
structure
til <- tiles(tmp) #the definition of the quadrats themselves
incircles <- lapply(til, incircle) #inscribe a circle in each quadrat
#get the x-coord of the center of each circle
x0 <- unlist(lapply(incircles, function(z) { z$x }))
#get the y-coord of the center of each circle
y0 <- unlist(lapply(incircles, function(z) { z$y }))
m2 <- unlist(lapply(til, function(x) x[[c(4,1,4)]])) #extract the area
of each polygon
d <- data.frame(x0, y0, Q, m2) #stick it all back together in a
data.frame
head(d)
As a reminder - If you're unhappy with the default plotting
behaviour, just type "plot.quadratcount" (no parentheses!) at the
prompt to look at the definition of the function, and write a custom
function that suits your needs.
HTH,
Dr. Anna E. Marburg
Ecosystem Processes Team
Landcare Research
P O Box 40
Lincoln 7640
NEW ZEALAND
phone + 64 3 321 9729
MarbugA at landcareresearch.co.nz
More information about the R-sig-Geo
mailing list