stack
), 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-layer) file. The can also be created from SpatialPixels*, SpatialGrid*, and Extent objects, and from a three-dimensional array.## S3 method for class 'character':
brick(x, ...)
## S3 method for class 'RasterStack':
brick(x, values=TRUE, nl, filename='', ...)
## S3 method for class 'RasterBrick':
brick(x, nl, ...)
## S3 method for class 'RasterLayer':
brick(x, ..., values=TRUE, nl=1, filename='')
## S3 method for class 'missing':
brick(nrows=180, ncols=360, xmn=-180, xmx=180, ymn=-90, ymx=90, nl=1, crs)
## S3 method for class 'Extent':
brick(x, nrows=10, ncols=10, crs=NA, nl=1)
## S3 method for class 'array':
brick(x, xmn=0, xmx=1, ymn=0, ymx=1, crs=NA, transpose=FALSE)
## S3 method for class 'big.matrix':
brick(x, template, filename='', ...)
## S3 method for class 'SpatialGrid':
brick(x)
## S3 method for class 'SpatialPixels':
brick(x)
TRUE
, the cell values of 'x
' are copied to the RasterBrick object that is returnedTRUE
, the values in the array are transposedx
is a RasterLayer, the additional arguments can be used to pass additional Raster* objects.
If there is a filename
argument, the additional arguments are as for writeRaster
. The big.matrix most have rows representing cells and columns representing layers.
If x
represents a filename there is the following additional argument:
native
: logical. If TRUE
(not the default), reading and writing of IDRISI, BIL, BSQ, BIP, and Arc ASCII files is done with native (raster package) drivers, rather then via rgdal.
In addition, if x
is a NetCDF filename there are the following additional arguments:
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))
lvar
: integer > 0 (default=3). To select the 'level variable' (3rd dimension variable) to use, if the file has 4 dimensions (e.g. depth instead of time)
level
: integer > 0 (default=1). To select the 'level' (4th dimension variable) to use, if the file has 4 dimensions, e.g. to create a RasterBrick of weather over time at a certain height.
To use NetCDF files the ncdf
or the ncdf4
package needs to be available. If both are available, ncdf4
is used. Only the ncdf4
package can read the most recent version (4) of the netCDF format (as well as older versions), for windows it not available on CRAN but can be downloaded raster
b <- brick(system.file("external/rlogo.grd", package="raster"))
b
nlayers(b)
names(b)
extract(b, 870)
Run the code above in your browser using DataLab