raster (version 1.0.4)

trim: Trim

Description

Trim (shrink) a RasterLayer by removing outer rows and columns that have no data. Or remove the whitespace before or after a string of characters.

Usage

trim(x, ...)

Arguments

x
A RasterLayer object or a character string
...
additional arguments. See Details.

Value

  • If x is a RasterLayer, a new RasterLayer object (in the R environment), and in some cases the side effect of a new file on disk. A character string If x is a character string.

Details

If x is a RasterLayer, the following additional arguments can be passed, to replace default values for this function rll{ padding Integer. Number of outer rows/columns with NA values to keep; default=0 filename Output filename. Default = '' format Character. Output file type. See writeRaster datatype Character. Output data type; can be 'INT', 'FLT', or a complete datatype description, see dataType overwrite Logical. If TRUE, "filename" will be overwritten if it exists progress Character. Valid values are "text", "tcltk", "windows" (on that platform only) and "" }

Examples

Run this code
r1 <- raster(ncol=36,nrow=18)
r1[309:310] <- 1:2
r1[353:355] <- 3:5
r1[400] <- 6
s <- trim(r1) 


trim("hi folks  ")

Run the code above in your browser using DataCamp Workspace