flip function

Flip

Flip

Flip the values of a Raster* object by inverting the order of the rows (direction=y) or the columns direction='x'. methods

## S4 method for signature 'RasterLayer' flip(x, direction='y', filename='', ...) ## S4 method for signature 'RasterStackBrick' flip(x, direction='y', filename='', ...)

Arguments

  • x: Raster* object
  • direction: Character. 'y' or 'x'; or 1 (=x) or 2 (=y)
  • filename: character. Output filename (optional)
  • ...: if x is a Raster* object, additional arguments as for writeRaster

Returns

RasterLayer or RasterBrick

See Also

transpose: t, rotate

Examples

r <- raster(nrow=18, ncol=36) m <- matrix(1:ncell(r), nrow=18) values(r) <- as.vector(t(m)) rx <- flip(r, direction='x') values(r) <- as.vector(m) ry <- flip(r, direction='y')
  • Maintainer: Robert J. Hijmans
  • License: GPL (>= 3)
  • Last published: 2025-03-28