diversity <- apply(mol.tab,1,function(x) sum(x>0))
gives the number of distinct trees located at each point
For example, for point 2251, we have
> lansing.tab[2251,]
blackoak hickory maple misc redoak whiteoak
0 0 7 1 2 5
which gives
> diversity[2251]
2251
4
Thanks for the code, Marcelino
2011/5/15 Matevž PavliÄ <[email protected]>
> Hi Marcelino,
>
> Was out of the office for a while...
> Thanks for the help. I think this could work...but can you tell me what
> this line does?
>
> diversity <- apply(mol.tab,1,function(x) sum(x>0))
>
> i cant figure out how diversity is calculated here?
>
> Thanks again for the help,
>
> matevz
>
> -----Original Message-----
> From: Marcelino de la Cruz [mailto:[email protected]]
> Sent: Thursday, May 12, 2011 2:03 PM
> To: Matevž PavliÄ
> Cc: [email protected]
> Subject: Re: [R-sig-Geo] density /diversity of points
>
> On 12/05/2011 13:12, Matevž PavliÄ wrote:
> > Hi all,
> >
> >
> >
> > I have a point data set (SHP) with coordinates and a attribute (i.e. type
> of point).
> >
> > These points are scattered around a fairly big area. What i would like to
> do is to find a sub-area where density of points sombined with the diversity
> of type is the biggest.
> >
> > Does anyone have any idea iff this is somehowe possible to do in R?
> > Any idea would be greatly aprpeciated,
> >
> >
> 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
>
>
>
> --
> _________________________________
>
> Marcelino de la Cruz Rot
> Departamento de Biologia Vegetal
> E.U.T.I. Agricola
> Universidad Politecnica de Madrid
> 28040 Madrid
> Tel: 34913365654
> _________________________________
> _______________________________________________
> R-sig-Geo mailing list
> [email protected]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo