Learn R Programming

raster (version 1.9-13)

brick: Create a RasterBrick object

Description

A RasterBrick is a multi-layer raster object. They are typically created from a multi-band file; but they can also exist entirely in memory. They are similar to a RasterStack, but processing time should be shorter when using a RasterBrick. Yet they are less flexible as they can only point to a single file. A RasterBrick can be created from RasterLayer objects, from a RasterStack, or from a (multi-band) file. The can also be created from SpatialPixels*, SpatialGrid*, and Extent objects, and from an three-dimensional array.

Usage

brick(x, ...)

Arguments

x
Filename (character), Raster* object, array, SpatialGrid*, SpatialPixels*, Extent, or list of Raster* objects
...
Additional arguments. See under Details

Value

  • RasterBrick object

Methods

1) Create a RasterBrick from a file brick(x, ...) rll{ x character. A filename of a file that the raster package can read. Supported file types are the 'native' raster package format and those that can be read via rgdal. See readGDAL help for supported file types. ... additional arguments. } Additional arguments: rll{ native Logical. Default is FALSE except when package rgdal is missing. If TRUE, reading and writing of IDRISI, BIL, BSQ, BIP, and Arc ASCII files is done with native (raster package) drivers, rather then via rgdal. 'raster', RSAGA, and netcdf format files are always read with native drivers. } For netCDF files (CF convention): rll{ varname character. The variable name (e.g. 'altitude' or 'precipitation'. If not supplied and the file has multiple variables are a guess will be made (and reported)) band integer > 0. The 'band' (layer) number of the file. E.g., the 'time' variable (if there are any) (default=NA) level integer > 0. To select the 'level' (4th dimension variable) to use, if the data has 4 dimensions (default=1) } To read netCDF files, the ncdf package needs to be available. 2) Create a RasterBrick from scratch brick(nrows=180, ncols=360, xmn=-180, xmx=180, ymn=-90, ymx=90, crs="+proj=longlat +datum=WGS84", nl=1) rll{ nrows number of rows ncols number of columns xmn minimum x coordinate (left border) xmx maximum x coordinate (right border) ymn minimum y coordinate (bottom border) ymx maximum y coordinate (top border) crs Character or object of class CRS. PROJ4 type description of a Coordinate Reference System (map projection) nl the desired number of layers } (item x is 'missing' in this case) 3) Create a RasterBrick from an Extent object brick(x, nrows=10, ncols=10, crs=NA, nl=1) rll{ x Extent object nrows number of rows ncols number of columns crs Character or object of class CRS. PROJ4 type description of a Coordinate Reference System (map projection) nl the desired number of layers } 4) Create a RasterBrick from a RasterStack brick(x, values=TRUE, nl) rll{ x a RasterStack object values Logical. If TRUE, the values of the RasterStack are transferred to the RasterBrick nl the desired number of layers (optional. If set, values becomes FALSE } 5) Create a RasterBrick from a RasterLayer or RasterBrick brick(x, nl=1) This copies the parameters of a RasterStack object to a new RasterBrick. The values of the RasterStack are transferred to the RasterBrick, unless values=FALSE. rll{ x a Raster* object nl the desired number of layers } 6) Create a RasterBrick from a SpatialPixels* or SpatialGrid* brick(x, layer=0) 7) Create a RasterBrick from an array The default extent is set to be between 0 and 1 in the x and y direction but can be changed at creation of the RasterLayer object or later. You can also provide a projection. function(x, xmn=0, xmx=1, ymn=0, ymx=1, crs=NA, transpose=FALSE) rll{ x three-dimensional array (rows, columns, layers) xmn minimum x coordinate (left border) xmx maximum x coordinate (right border) ymn minimum y coordinate (bottom border) ymx maximum y coordinate (top border) crs PROJ4 type description of a map projection (optional) transpose Logical. Transpose the data? }

See Also

raster

Examples

Run this code
b <- brick(system.file("external/rlogo.grd", package="raster"))
b
nlayers(b)
layerNames(b)
extract(b, 870)

Run the code above in your browser using DataLab