Learn R Programming

raster (version 1.8-3)

getValuesBlock: Get a block of raster cell values

Description

getValuesBlock returns values for a block (rectangular area) of values of a Raster* object. It will take them from memory if available, else it will read them from disk.

Usage

getValuesBlock(x, row, ...)

Arguments

x
Raster* object
row
Numeric. Row number, should be between 1 and nrow(x), or missing in which case all values are returned
...
Additional arguments, see Details

Value

  • vector (x=RasterLayer) or matrix

Details

Additional arguments: rll{ nrows Integer. How many rows? Default is 1 col Integer. Start column. Default is 1 ncols Integer. How many columns? Default is the number of colums left after the start column lyrs Integer (vector). Which layers? Default is all layers (1:nlayers(x)) }

Examples

Run this code
r <- raster(system.file("external/test.grd", package="raster"))
b <- getValuesBlock(r, row=100, nrows=3, col=10, ncols=5)
b 
b <- matrix(b, nrow=3, ncol=5, byrow=TRUE)
b

logo <- brick(system.file("external/rlogo.grd", package="raster"))
getValuesBlock(logo, row=35, nrows=3, col=50, ncols=3, lyrs=2:3)

Run the code above in your browser using DataLab