简体   繁体   English

使用 Earth Mover 距离 (EMD) 计算 .tif 栅格之间空间利用率的相似性

[英]Calculate similarity in spatial utilization between .tif rasters using Earth Mover's Distance (EMD)

I am analyzing animal tracking data within an acoustic receiver array using dynamic Brownian bridge movement models.我正在使用动态布朗桥运动模型分析声学接收器阵列内的动物跟踪数据。 The dataset contains an animal identifier and every detection on a receiver has a timestamp and a lat/lon coordinates (in decimal degrees).数据集包含一个动物标识符,接收器上的每个检测都有一个时间戳和一个纬度/经度坐标(十进制度)。 Further, there is are two additional grouping variables "studyperiod" and "sgroup".此外,还有两个额外的分组变量“studyperiod”和“sgroup”。

  Elasmo            Datetime      Lat       Lon studyperiod sgroup
1 X10141 2019-02-13 15:29:00 25.72441 -79.30922      IS2019  naive
2 X10141 2019-02-13 15:44:00 25.72441 -79.30922      IS2019  naive
3 X10141 2019-02-13 15:48:00 25.72441 -79.30922      IS2019  naive
4 X10141 2019-02-13 17:17:00 25.72441 -79.30922      IS2019  naive
5 X10141 2019-02-13 17:20:00 25.72441 -79.30922      IS2019  naive
6 X10141 2019-02-13 18:00:00 25.72441 -79.30922      IS2019  naive

I then used the GitHub package 'dBBMMhomeRange' (/https://github.com/SimonDedman/dBBMMhomeRange) to calculate individual-level Utilization distributions first, which are then scaled, weighted, summed to group-level UDs.然后,我首先使用 GitHub package 'dBBMMhomeRange' (/https://github.com/SimonDedman/dBBMMhomeRange) 计算个人级别的利用率分布,然后对其进行缩放、加权、汇总到组级别的 UD。 The resulting group-level UDs are saved as.ascii rasters.生成的组级 UD 保存为 .ascii 栅格。 As the rasters had different extents, I imported them into ArcMap and specified a shared extent within the program.由于栅格有不同的范围,我将它们导入 ArcMap 并在程序中指定一个共享范围。 Rasters with the same shared extent were then exported from Arcmap and imported into R.然后将具有相同共享范围的栅格从 Arcmap 导出并导入 R。 The rasters have the following properties:栅格具有以下属性:

r1 <- raster("~/N_IS2017_sc.tif")
r4 <- raster("~/N_IS2020_sc.tif")

> r1;r4
class      : RasterLayer 
dimensions : 1450, 1264, 1832800  (nrow, ncol, ncell)
resolution : 50, 50  (x, y)
extent     : -31658.67, 31541.33, -36085.92, 36414.08  (xmin, xmax, ymin, ymax)
crs        : NA 
source     : N_IS2017_sc.tif 
names      : N_IS2017_sc 
values     : 0, 0.0003713508  (min, max)

class      : RasterLayer 
dimensions : 1450, 1264, 1832800  (nrow, ncol, ncell)
resolution : 50, 50  (x, y)
extent     : -31658.67, 31541.33, -36085.92, 36414.08  (xmin, xmax, ymin, ymax)
crs        : NA 
source     : N_IS2020_sc.tif 
names      : N_IS2020_sc 
values     : 0, 0.0004588088  (min, max)


Now, I would like to use Earth Mover's Distance as described by Kranstauber et al.现在,我想使用 Kranstauber 等人描述的 Earth Mover 距离。 (2016) to calculate similarity in space use between the different groups. (2016)计算不同组之间空间使用的相似性。 To do so I used emdDists() function from the move package.为此,我使用了移动 package 中的 emdDists() function。

## create a raster stack
allrasters <- stack(r1,r4)

## EMD
emdDists <- emd(allrasters/cellStats(allrasters, sum), threshold = 700)

However, the function starts running but always crashes.但是,function 开始运行但总是崩溃。 Which makes me think that something I did was not correct.这让我觉得我做的事情是不正确的。

So, this brings me to my two questions:所以,这给我带来了两个问题:

  1. The corresponding paper uses a UDStack as object to supply to the EMDDists().相应的论文使用 UDStack 作为 object 来提供给 EMDDists()。 So I am unsure if it is possible to implement the EMD approach for here described.tif rasters as well?所以我不确定是否也可以为这里描述的.tif 栅格实施 EMD 方法?

  2. If correct, are there ways to reduce the calculation power demands to R?如果正确,有没有办法降低对 R 的计算能力需求?

Thanks to comments from Chris (see above for background) I found the answer to my question.感谢 Chris 的评论(背景见上文),我找到了问题的答案。 The important step was to convert the imported rasters to.UD class objects so that they can be used to create a UDStack.重要的步骤是将导入的栅格转换为 .UD class 对象,以便它们可以用于创建 UDStack。 The code is pretty straightforward and quick using functions from the "move" package and the "move" package.使用“move”package 和“move”package 中的函数,代码非常简单快捷。

library("move")
library("raster")

# Import rasters
r1 <- raster("~/R1.tif")
r2 <- raster("~/R2.tif")
r3 <- raster("~/R3.tif")

# create .UD class rasters
r1ud <- new(".UD", r1)
r2ud <- new(".UD", r2)
r3ud <- new(".UD", r3)

# create a UDStack needed for emd()
stk <- UDStack(as.list(r1ud, r2ud, r3ud))

# 'stk' can now be used within the emd() function as described by Kranstauber et al. 2017

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM