spatial.tools (version 1.6.0)

getValuesBlock_enhanced: Easier-to-use function for grabbing a block of data out of a Raster*.

Description

Easier-to-use function for grabbing a block of data out of a Raster*.

Usage

getValuesBlock_enhanced(x, r1 = 1, r2 = nrow(x), c1 = 1, c2 = ncol(x),
  lyrs = seq(nlayers(x)), format = "array", ...)

Arguments

x

Raster* Some input Raster* object.

r1

Numeric. The start row of the chunk.

r2

Numeric. The end row of the chunk.

c1

Numeric. The start column of the chunk.

c2

Numeric. The end row of the chunk.

lyrs

Numeric. Vector of layer IDs. Defaults to all layers (1:nlayers(x)).

format

Character. See Details.

...

Other parameters.

Value

An array or raster object.

Details

This allows for a larger number of output formats to be generated when extracting chunks of data from a Raster* object. If format="array" (default), the chunk will be returned in a 3-d array with dimensions representing column,row,and layer. If "raster", the chunk will be returned as a Raster* object. If "data.frame", it will be returned as a data.frame. If "data.frame.dims", it will return a list, where the first component (named "values") is the same as the data.frame when using format="data.frame", and the second component (named "dim") is the dimensions of the extracted chunk.

See Also

getValues

Examples

Run this code
# NOT RUN {
library("raster")
tahoe_highrez <- brick(system.file("external/tahoe_highrez.tif", package="spatial.tools"))
mychunk <- getValuesBlock_enhanced(tahoe_highrez,r1=100,r2=110,c1=20,c2=50)
class(mychunk)
dim(mychunk)
mychunk_raster <- getValuesBlock_enhanced(tahoe_highrez,r1=100,r2=110,c1=20,c2=50,format="raster")
mychunk_raster
# }

Run the code above in your browser using DataLab