zshift: Offset Raster or Matrix Values

View source: R/zshift.R

zshiftR Documentation

Offset Raster or Matrix Values

Description

Calculates a matrix of values with a negative or positive, x or y, offset.

Usage

zshift(r, xdist = 0, ydist = 0, xrm, yrm, scale = FALSE)

Arguments

r

A raster or matrix.

xdist

Numeric indicating the number and direction (+, -) of columns for the offset.

ydist

Numeric indicating the number and direction (+, -) of rows for the offset.

xrm

Numeric value or vector indicating the number of columns to be removed from the final matrix. If not set, this value defaults to xdist. Positive values remove columns from the right, while negative values remove columns from the left. The absolute value of xrm must be >= abs(xdist).

yrm

Numeric value or vector indicating the number of rows to be removed from the final matrix. If not set, this value defaults to ydist. Positive values remove rows from the bottom, while negative values remove rows from the top. The absolute value must be >= abs(ydist).

scale

Logical. Indicates whether or not to scale the values of the raster.

Value

A numeric vector of values created from a matrix of the values with the specified offset. The vector is created from a matrix with xrm fewer columns and yrm fewer rows than the original raster value matrix.

Examples

# import raster image
data(normforest)
normforest <- terra::unwrap(normforest)

# remove right and bottom borders 2 deep
noborder <- zshift(normforest, xdist = 2, ydist = 2)

geodiv documentation built on Oct. 6, 2023, 1:07 a.m.