Learn R Programming

raster (version 1.8-3)

trim: Trim

Description

Trim (shrink) a Raster* object 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 Raster* object or a character string
...
additional arguments. See Details.

Value

  • A RasterLayer or RasterBrick object (if x is a Raster* object). A character string If x is a character string.

Details

If x is a Raster* object, 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. "text", "window", or "" (the default, no progress bar) }

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 DataLab