[R] Spatstat - Several density plots using the same scale
Adrian Baddeley
adrian at maths.uwa.edu.au
Fri Oct 10 08:26:07 CEST 2008
Arthur Weiss wrote:
>
>> Hi everyone,
>>
>> I am using the package "spatstat" for ploting kernel maps of my data.
>> It is a marked point pattern, the result of mosquito surveillance in a
>> area in a week.
>> For each trap, the number of individuals captured is the mark of the
>> point.
>>
>>> plot(density(X, weights=X$marks))
>>
>> makes a nice kernel, but the problem is that I've got several weeks and
>> for each week the density is re-scaled, which makes comparisons useless.
>> I've been trying to find some way to pass the scale limits to the
>> function
>> but just couldn't find.
See help(plot.im) for information about how to plot a pixel image in
spatstat. The argument 'zlim' controls the range of numerical values
that are mapped to colours in the display.
If you have, say, 4 pixel images Z1, Z2, Z3, Z4 and want to plot them
all with the same colour map, try the following.
Zlist <- list(week1=Z1, week2=Z2, week3=Z3, week4=Z4)
Zrange <- range(unlist(
lapply(Zlist, function(x){summary(x)$range})))
plot(as.listof(Zlist), zlim=Zrange, ncols=2)
However, it's not clear that the command density() is really what you
want to use in this context. This command estimates the
spatially-varying average intensity (`density') of points. Are the
insect traps at fixed locations that were chosen by the experimenter? If
so, then it is somewhat meaningless to estimate their average
density.... What you need is a method for spatially interpolating the
insect counts (number of trapped insects) observed at these locations.
In spatstat you can use the command 'smooth.ppp' to perform
kernel-weighted spatial interpolation. If the insect counts are small,
then it would be more appropriate to do spatial Poisson regression
(using other packages).
Adrian Baddeley
More information about the R-help
mailing list