Learn R Programming

move (version 2.1.0)

emd: Earth movers distance

Description

Calculates the disimilairty, measured as the earth movers distance.

Usage

# S4 method for SpatialPoints,SpatialPoints
emd(x,y, gc = FALSE, threshold = NULL,...)
  # S4 method for RasterLayer,RasterLayer
emd(x,y, ...)

Arguments

x

A Raster, Raster stack/brick or SpatialPoints object, it is also possible to provide UD objects. In case of spatial points data frame the first columns of data is used as weights. In case of SpatialPoints all points are weighted equally.

y

A Raster or SpatialPoints.

gc

True if great circle distances should be used.

threshold

The maximal distance over which locations are compaired.

...

Currently not used

Value

An dist object is returned

References

Kranstauber, B., Smolla, M., Safi,K., Similarity in spatial utilization distributions measured by the Earth Mover's Distance.

Examples

Run this code
# NOT RUN {
  data(dbbmmstack)
  values(dbbmmstack)[values(getVolumeUD(dbbmmstack))>.999999]<-0
  stk<-(dbbmmstack/cellStats(dbbmmstack,sum))
  emd(stk[[1]],stk[[2]])
  emd(stk)
  emd(stk, threshold=10000)
  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)
# }

Run the code above in your browser using DataLab