重新分类栅格包 [r] 中 include.lowest 的含义是什么

What is the meaning of include.lowest in reclassify raster package [r]

给定开内(不包括端点)和闭区间(包括端点)的定义,right中的论证就很容易理解了reclassify。但我对 include.lowest 的说法感到困惑。它提到

indicating if a value equal to the lowest value in rcl (or highest value in the second column, for right = FALSE) should be included

rcl 中的最低值将是第一个值,根据 right 默认情况下不包含该值,因此将 include.lowest 设置为 true 将包含最低值。但是关于 "highest value in the second column" 的部分,我不明白它指的是什么。 "for right = FALSE" 是什么意思?无论如何,第二列中的最大值应该已经包括在内。

所以如果我有 rcl=c(0,1,5, 1,Inf,10) 默认情况下这意味着 0>x>=1 变成 5,而 x>1 变成 10。如果 include.lowest 是真的吗? 0>=x>=1 和....?

我觉得很困惑,因为重新分类帮助文件中给出的示例说的是

all values >= 0 and <= 0.25 become 1, etc. m <- c(0, 0.25, 1, 0.25, 0.5, 2, 0.5, 1, 3)

但是示例中的重新分类函数不使用 include.lowest 所以它不应该是所有值 >= 0 而是 >0.

编辑:我发现帮助页面非常混乱,给出的答案是帮助页面中示例的解释是错误的。

正如我在评论中所说,rightinclude.lowest 的工作方式与 R 基本函数 cut 完全相同。为了简单说明,我将在下面使用 cut,向量 1:10 和断点 1、5、10。

默认right = TRUE,所以所有的区间都是左开右闭,所以我们有两个区间:(1, 5](5, 10]。注意这些一起给出了另一个左开右闭区间 (1, 10],其中不包括最低的 1include.lowest = TRUE 会考虑 [1, 10] 并做 [1,5], (5,10]。比较

cut(1:10, right = TRUE, breaks = c(1, 5, 10))
# [1] <NA>   (1,5]  (1,5]  (1,5]  (1,5]  (5,10] (5,10] (5,10] (5,10] (5,10]
#Levels: (1,5] (5,10]

cut(1:10, right = TRUE, breaks = c(1, 5, 10), include.lowest = TRUE)
# [1] [1,5]  [1,5]  [1,5]  [1,5]  [1,5]  (5,10] (5,10] (5,10] (5,10] (5,10]
#Levels: [1,5] (5,10]

现在,如果我们设置right = FALSE,所有区间将左闭右开:[1, 5)[5, 10)。在这种情况下,include.lowest = TURE 基本上包含最高值。比较

cut(1:10, right = FALSE, breaks = c(1, 5, 10))
# [1] [1,5)  [1,5)  [1,5)  [1,5)  [5,10) [5,10) [5,10) [5,10) [5,10) <NA>  
#Levels: [1,5) [5,10)

cut(1:10, right = FALSE, breaks = c(1, 5, 10), include.lowest = TRUE)
# [1] [1,5)  [1,5)  [1,5)  [1,5)  [5,10] [5,10] [5,10] [5,10] [5,10] [5,10]
#Levels: [1,5) [5,10]

返回raster::reclassify

I find it confusing because the example given on the reclassify help file says that

all values >= 0 and <= 0.25 become 1, etc. m <- c(0, 0.25, 1, 0.25, 0.5, 2, 0.5, 1, 3)

为什么?上面 m,你有 rcl 矩阵:

matrix(m, ncol = 3L, byrow = TRUE, dimnames = list(NULL, c("from", "to", value)))
#     from   to value
#[1,] 0.00 0.25     1
#[2,] 0.25 0.50     2
#[3,] 0.50 1.00     3

使用 right = TRUEinclude.lowest = FALSE(默认行为),您有

(0.00, 0,25]   --->   1
(0.25, 0.50]   --->   2
(0.50, 1.00]   --->   3

right = TRUEinclude.lowest = TRUE,你有

[0.00, 0,25]   --->   1
(0.25, 0.50]   --->   2
(0.50, 1.00]   --->   3