powered by
Trim (shrink) a Raster* object by removing outer rows and columns that all have the same value (e.g. NA).
Or remove the whitespace before or after a string of characters (or a matrix, or the character values in a data.frame).
# S4 method for Raster trim(x, padding=0, values=NA, filename='', ...) # S4 method for character trim(x, ...)
Raster* object or a character string
numeric. Value(s) based on which a Raster* should be trimmed
integer. Number of outer rows/columns to keep
character. Optional output filename
If x is a Raster* object: additional arguments as for writeRaster
x
writeRaster
A RasterLayer or RasterBrick object (if x is a Raster* object) or a character string (if x is a character string).
# NOT RUN { r <- raster(ncol=18,nrow=18) r[39:49] <- 1 r[113:155] <- 2 r[200] <- 6 s <- trim(r) trim(" hi folks ! ") # }
Run the code above in your browser using DataLab