Skip to content
Prev 11668 / 29559 Next

density /diversity of points

On 12/05/2011 13:12, Matev? Pavli? wrote:
To your first question:

library(fortunes)
fortune("Yoda")

;-)

More seriously, you could  transform your shp data in a ppp object with 
spatstat. See the vignette in spatstat. Then you can use some functions 
there, for example (with the data set lansing):

library(spatstat)
data(lansing)
plot(lansing)
# get an estimate of point density
lansing.den <- density.ppp(lansing)
plot(lansing.den)

# get an estimate of point diversity (here, for the shake of brevity, at 
the points themselves)
lansing.tab<- marktable(lansing,R=0.05)
diversity <- apply(lansing.tab,1,function(x) sum(x>0))
lansing.div <- setmarks(lansing,diversity)
lansing.div.s <-smooth.ppp(lansing.div)

plot(lansing.div.s)

# select areas with arbitrary high values of  density and diversity
plot(eval.im(lansing.div.s >4.5 & (lansing.den/max(lansing.den))>0.9))


HTH. Cheers,

Marcelino