Creates a square matrix representing annulus position values of 1 and defined null

annulus.matrix(scale = 3, inner.scale = 0, outer.scale = 0, null.value = 0)

Arguments

scale

Number of rings (defines dimensions of matrix)

inner.scale

Number of inner rings to set to null.value

outer.scale

Number of outer rings to set to null.value

null.value

Value to set inner and outer scale(s) to

Value

A matrix object with defined null.value and 1, representing retained rings

Note

This function will return a matrix of 1 and defined null.value based on a specification of the scale, inner scale and outer scale. The scale defines how many rings will be represented in the matrix based on (2 * scale - 1). So, a scale of 3 will result in a 5x5 matrix. The inner.scale and outer.scale arguments represent the > and < rings that will be set to the defined null.value (see examples). The resulting matrix can be used as the specified window in a focal function.

Author

Jeffrey S. Evans <jeffrey_evans@tnc.org>

Examples

annulus.matrix(5) # 5 concentric rings
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] #> [1,] 1 1 1 1 1 1 1 1 1 #> [2,] 1 1 1 1 1 1 1 1 1 #> [3,] 1 1 1 1 1 1 1 1 1 #> [4,] 1 1 1 1 1 1 1 1 1 #> [5,] 1 1 1 1 0 1 1 1 1 #> [6,] 1 1 1 1 1 1 1 1 1 #> [7,] 1 1 1 1 1 1 1 1 1 #> [8,] 1 1 1 1 1 1 1 1 1 #> [9,] 1 1 1 1 1 1 1 1 1
annulus.matrix(5, 3) # 5 concentric rings with the 3 inner set to 0
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] #> [1,] 1 1 1 1 1 1 1 1 1 #> [2,] 1 1 1 1 1 1 1 1 1 #> [3,] 1 1 0 0 0 0 0 1 1 #> [4,] 1 1 0 0 0 0 0 1 1 #> [5,] 1 1 0 0 0 0 0 1 1 #> [6,] 1 1 0 0 0 0 0 1 1 #> [7,] 1 1 0 0 0 0 0 1 1 #> [8,] 1 1 1 1 1 1 1 1 1 #> [9,] 1 1 1 1 1 1 1 1 1
annulus.matrix(5, 3, null.value=NA) # 5 concentric rings with the 3 inner set to NA
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] #> [1,] 1 1 1 1 1 1 1 1 1 #> [2,] 1 1 1 1 1 1 1 1 1 #> [3,] 1 1 NA NA NA NA NA 1 1 #> [4,] 1 1 NA NA NA NA NA 1 1 #> [5,] 1 1 NA NA NA NA NA 1 1 #> [6,] 1 1 NA NA NA NA NA 1 1 #> [7,] 1 1 NA NA NA NA NA 1 1 #> [8,] 1 1 1 1 1 1 1 1 1 #> [9,] 1 1 1 1 1 1 1 1 1
annulus.matrix(5, 3, 5) # 5 rings with 3 inner and 5 outer set to 0
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] #> [1,] 0 0 0 0 0 0 0 0 0 #> [2,] 0 1 1 1 1 1 1 1 0 #> [3,] 0 1 0 0 0 0 0 1 0 #> [4,] 0 1 0 0 0 0 0 1 0 #> [5,] 0 1 0 0 0 0 0 1 0 #> [6,] 0 1 0 0 0 0 0 1 0 #> [7,] 0 1 0 0 0 0 0 1 0 #> [8,] 0 1 1 1 1 1 1 1 0 #> [9,] 0 0 0 0 0 0 0 0 0
annulus.matrix(9, 3, 7) # 9 rings with 3 inner and 7 outer set to 0
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] #> [1,] 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [2,] 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [3,] 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [4,] 0 0 0 1 1 1 1 1 1 1 1 1 1 #> [5,] 0 0 0 1 1 1 1 1 1 1 1 1 1 #> [6,] 0 0 0 1 1 1 1 1 1 1 1 1 1 #> [7,] 0 0 0 1 1 1 0 0 0 0 0 1 1 #> [8,] 0 0 0 1 1 1 0 0 0 0 0 1 1 #> [9,] 0 0 0 1 1 1 0 0 0 0 0 1 1 #> [10,] 0 0 0 1 1 1 0 0 0 0 0 1 1 #> [11,] 0 0 0 1 1 1 0 0 0 0 0 1 1 #> [12,] 0 0 0 1 1 1 1 1 1 1 1 1 1 #> [13,] 0 0 0 1 1 1 1 1 1 1 1 1 1 #> [14,] 0 0 0 1 1 1 1 1 1 1 1 1 1 #> [15,] 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [16,] 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [17,] 0 0 0 0 0 0 0 0 0 0 0 0 0 #> [,14] [,15] [,16] [,17] #> [1,] 0 0 0 0 #> [2,] 0 0 0 0 #> [3,] 0 0 0 0 #> [4,] 1 0 0 0 #> [5,] 1 0 0 0 #> [6,] 1 0 0 0 #> [7,] 1 0 0 0 #> [8,] 1 0 0 0 #> [9,] 1 0 0 0 #> [10,] 1 0 0 0 #> [11,] 1 0 0 0 #> [12,] 1 0 0 0 #> [13,] 1 0 0 0 #> [14,] 1 0 0 0 #> [15,] 0 0 0 0 #> [16,] 0 0 0 0 #> [17,] 0 0 0 0