## with a DBBMMStack object
data(dbbmmstack)
## to optimize the calculation, the cells outside of the 99.99% UD contour
# are removed by setting them to zero.
values(dbbmmstack)[values(getVolumeUD(dbbmmstack))>.999999]<-0
## transform each layer to a probability surface (i.e. sum of their values is 1)
stk<-(dbbmmstack/cellStats(dbbmmstack,sum))
emd(stk[[1]],stk[[2]])
emd(stk)
emd(stk, threshold=10000)
## with a SpatiaPointsDataFrame
x<-SpatialPointsDataFrame(cbind(c(1:3,5),2), data=data.frame(rep(.25,4)))
y<-SpatialPointsDataFrame(coordinates(x), data.frame(c(0,.5,.5,0)))
emd(x,y)
emd(x,y,threshold=.1)
## with a DBBMMBurstStack object, to compare the utilization
# distributions of e.g. different behaviors
data(leroy)
leroyB <- burst(x=leroy,f=c(rep(c("Behav.1","Behav.2"),each=400),rep("Behav.1", 118)))
leroyBp <- spTransform(leroyB, CRSobj="+proj=aeqd +ellps=WGS84", center=TRUE)
leroyBdbb <- brownian.bridge.dyn(object=leroyBp[750:850], location.error=12, raster=600,
ext=.45, time.step=15/15, margin=15)
## transform the DBBMMBurstStack into a UDStack
leoryBud <- UDStack(leroyBdbb)
## to optimize the calculation, the cells outside of the 99.99% UD contour
# are removed by setting them to zero.
values(leoryBud)[values(getVolumeUD(leoryBud))>.999999]<-0
## transform each layer to a probability surface (i.e. sum of their values is 1)
stk2<-(leoryBud/cellStats(leoryBud,sum))
emd(stk2)
Run the code above in your browser using DataLab