SpatRaster粗糙度指数方程(地形,v =“roughness”)是如何工作的?

huangapple go评论64阅读模式
英文:

How does the equation for the SpatRaster roughness index (terrain, v = "roughness") work?

问题

以下是已翻译的内容:

"terra"包提供并描述以下地形指标:

x <- terrain(x, v="roughness")
x <- terrain(x, v="TPI")
x <- terrain(x, v="TRI")

我对如何根据包描述计算这些指标感到困惑,其中"roughness"被描述为"单元格及其8个周围单元格的最大值和最小值之间的差异"(Hijmans等人,2023年)。这在边缘和角单元格的情况下是如何工作的呢?我假设在这些情况下,计算会减少到一个单元格和其5个或3个周围单元格吗?

"ruggedness"(TRI)指数被描述为"单元格值与其8个周围单元格值的绝对差异的平均值"。以下是我从提供的描述中构想出这些指标的计算的图示。

SpatRaster粗糙度指数方程(地形,v =“roughness”)是如何工作的?

这是否提供了这些指标的正确解释?

如果这个解释是不正确的,那么我希望有人指出正确的方向(参考文献),或在这里解释。我有兴趣编写代码来计算DSM的16°坡度和1.3米的高程差,但认为地形指数会更好地指示这种栖息地模型的1.3米标准。

## > 16°坡度
habitat_slope_mat <- matrix(nrow = 2, ncol = 3)
habitat_slope_mat[1, ] <- c(0,16,0) # 从,到 = 0 不存在
habitat_slope_mat[2, ] <- c(16,minmax(x)[2],1) # 从,到 = 1 存在

habitat_slope <- classify(x, habitat_slope_mat, include.lowest=TRUE)

我查看了引用的参考文献,希望找到这个方法的公式,以帮助我思考如何处理1.3米的标准。但我无法找到进一步解释这种方法的书面/已发表描述。这篇论文在地形函数描述的引文中列出:

Jones, K.H., 1998. 用于计算DEM属性的不同算法的比较。计算与地球科学 24:315-323

这篇文章的正确标题(DOI:10.1016/S0098-3004(98)00032-6)是:"用于计算DEM属性的不同算法的比较"。我无法在那篇论文中找到粗糙度的公式,并对进一步阅读此主题感兴趣。

英文:

The terra package offers and describes the following terrain indices:

x &lt;- terrain(x, v=&quot;roughness&quot;)
x &lt;- terrain(x, v=&quot;TPI&quot;)
x &lt;- terrain(x, v=&quot;TRI&quot;)

I am confused on how this is calculated based on the package description of roughness as "the difference between the maximum and the minimum value of a cell and its 8 surrounding cells" (Hijmans et al. 2023). How does this work for edge and corner cells? I am assuming that the calculation reduces to a cell and its 5 or 3 surrounding cells in these cases?

The ruggedness (TRI) index is described as "the mean of the absolute differences between the value of a cell and the value of its 8 surrounding cells". The following is a graphic illustration of how I envision the calculation of these indices from the description provided.

SpatRaster粗糙度指数方程(地形,v =“roughness”)是如何工作的?
Does this provide a correct interpretation of these indices?

If this interpretation is incorrect, then I am hoping someone point me in the correct direction (a reference) or explain here. I am interested in coding to calculate a slope of 16&deg; from a DSM and an elevational difference of 1.3 m, but think that a terrain index would give a better indicator of the 1.3 m criterion for this habitat model.

## &gt; 16&#176; slope
habitat_slope_mat &lt;- matrix(nrow = 2, ncol = 3)
habitat_slope_mat[1, ] &lt;- c(0,16,0) # from,to = 0 absent
habitat_slope_mat[2, ] &lt;- c(16,minmax(x)[2],1) # from,to = 1 present

habitat_slope &lt;- classify(x, habitat_slope_mat, include.lowest=TRUE)

I looked at the cited references and was expecting to find the formula for this to help me think of the best way to treat the 1.3 m criterion. I have been unable to locate a written / published description that further explains the method. This paper is listed in the citations for the terrain function description:

Jones, K.H., 1998. A comparison of algorithms used to compute hill (sic) *terrain *as a property of the DEM. Computers & Geosciences 24: 315-323

The correct title for the article (DOI: 10.1016/S0098-3004(98)00032-6) is: "A comparison of algorithms used to compute hill *slope *as a property of the DEM". I cannot locate the formula for roughness in that paper and was interested in reading more on this topic.

答案1

得分: 1

以下是翻译好的部分:

The manual points to Wilson et al (2007) for terrain indices. It also shows how you can use focal instead of terrain to compute them.

手册指向Wilson et al (2007)来获取地形指数。它还展示了如何使用focal代替terrain来计算它们。

You can see for yourself what happens with small examples like this:

你可以亲自看看像这样的小例子会发生什么:

library(terra)
x <- rast(nrow=3, ncol=3, vals=c(1,2,3,1,2,1,1,2,8), ext=ext(0,1,0,1), crs="local")

as.matrix(x, wide=T)
#     [,1] [,2] [,3]
#[1,]    1    2    3
#[2,]    1    2    1
#[3,]    1    2    8

terrain(x, "roughness") |> as.matrix(wide=TRUE)
#     [,1] [,2] [,3]
#[1,]  NaN  NaN  NaN
#[2,]  NaN    7  NaN
#[3,]  NaN  NaN  NaN

focal(x, w=3, fun=function(x) {max(x) - min(x)}) |> as.matrix(wide=T)
#     [,1] [,2] [,3]
#[1,]   NA   NA   NA
#[2,]   NA    7   NA
#[3,]   NA   NA   NA

terrain(x, "TRI") |> as.matrix(wide=TRUE)
#     [,1]  [,2] [,3]
#[1,]  NaN   NaN  NaN
#[2,]  NaN 1.375  NaN
#[3,]  NaN   NaN  NaN

focal(x, w=3, fun=function(x) sum(abs(x[-5]-x[5]))/8) |> as.matrix(wide=T)
#     [,1]  [,2] [,3]
#[1,]   NA    NA   NA
#[2,]   NA 1.375   NA
#[3,]   NA    NA   NA

So the edges become missing (you could do other things via focal)

因此,边缘变得缺失(您可以通过focal进行其他操作)

Or look at the source code.

或者查看源代码

英文:

I am not sure if this question is appropriate here, as you do not seem to be asking a coding question.

The manual points to Wilson et al (2007) for terrain indices. It also shows how you can use focal instead of terrain to compute them.

You can see for yourself what happens with small examples like this:

library(terra)
x &lt;- rast(nrow=3, ncol=3, vals=c(1,2,3,1,2,1,1,2,8), ext=ext(0,1,0,1), crs=&quot;local&quot;)

as.matrix(x, wide=T)
#     [,1] [,2] [,3]
#[1,]    1    2    3
#[2,]    1    2    1
#[3,]    1    2    8

terrain(x, &quot;roughness&quot;) |&gt; as.matrix(wide=TRUE)
#     [,1] [,2] [,3]
#[1,]  NaN  NaN  NaN
#[2,]  NaN    7  NaN
#[3,]  NaN  NaN  NaN

focal(x, w=3, fun=\(x) {max(x) - min(x)}) |&gt; as.matrix(wide=T)
#     [,1] [,2] [,3]
#[1,]   NA   NA   NA
#[2,]   NA    7   NA
#[3,]   NA   NA   NA
 
terrain(x, &quot;TRI&quot;) |&gt; as.matrix(wide=TRUE)
#     [,1]  [,2] [,3]
#[1,]  NaN   NaN  NaN
#[2,]  NaN 1.375  NaN
#[3,]  NaN   NaN  NaN

focal(x, w=3, fun=\(x) sum(abs(x[-5]-x[5]))/8) |&gt; as.matrix(wide=T)
#     [,1]  [,2] [,3]
#[1,]   NA    NA   NA
#[2,]   NA 1.375   NA
#[3,]   NA    NA   NA

So the edges become missing (you could do other things via focal)

Or look at the source code.

huangapple
  • 本文由 发表于 2023年2月8日 13:27:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/75381679.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定