Learn R Programming

terra (version 0.4-3)

flip: Flip a raster

Description

Flip the values of a SpatRaster by inverting the order of the rows (vertical=TRUE) or the columns (vertical=FALSE).

Usage

# S4 method for SpatRaster
flip(x, vertical=TRUE, filename="", overwrite=FALSE, wopt=list(), ...)

Arguments

x

SpatRaster

vertical

logical. If TRUE, values are flipped by rows, if FALSE, values are flipped by columns

filename

character. Output filename. Optional

overwrite

logical. If TRUE, filename is overwritten

wopt

list. Options for writing files as in writeRaster

...

additional arguments. None implemented

Value

SpatRaster

See Also

transpose, rotate

Examples

Run this code
# NOT RUN {
r <- rast(nrow=18, ncol=36)
m <- matrix(1:ncell(r), nrow=18)
values(r) <- as.vector(t(m))
rx <- flip(r, vertical=FALSE)
values(r) <- as.vector(m)
ry <- flip(r, vertical=TRUE)
# }

Run the code above in your browser using DataLab