brick(x, ...)
brick(x, ...)
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
for supported file types.
...
additional arguments.
}
Additional arguments:
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):
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))
level
integer > 0 (default=3). To select the 'level' (4th dimension variable) to use, if the data has 4 dimensions
}
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)
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)
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)
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.
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)
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?
}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