eco.slide.matrix: Sliding window for matrix data

Description Usage Arguments Author(s) Examples

View source: R/eco.slide.matrix.R

Description

This program applies a function defined by the user, using a moving window (circle area or square) and assigning the value to the focal pixel.

Usage

1
2
3
4
5
6
7
8
eco.slide.matrix(
  mat,
  r,
  slide,
  fun,
  window = c("square", "circle"),
  within = TRUE
)

Arguments

mat

Input raster matrix.

r

Half a side for square, radius for circle, diagonal length for rhombus.

slide

Number of elements between two focal pixels, for column and row dimension

fun

Function to apply in each focal pixel.

window

Window type. Default "square".

within

Should the function be computed in focal pixels of the borders, only if the area is within the matrix? Default TRUE.

Author(s)

Leandro Roser learoser@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 

data(eco.test)
ras <- matrix(eco[["P"]][, 1], 15, 15)
image(ras)
ras.square <- eco.slide.matrix(ras, 1, 1, mean, "square")
image(ras.square)

# or allowing more control over the function:
ras.square <- eco.slide.matrix(ras, r = 3, slide = 1, function(x) mean(x, na.rm = TRUE), "square")
image(ras.square)

# sliding a circle:
ras.circle <- eco.slide.matrix(ras, r = 3, slide = 1, mean, "circle", within = FALSE)
image(ras.circle) 


## End(Not run)

EcoGenetics documentation built on July 8, 2020, 5:46 p.m.