getValuesBlock_stackfix: Get a block of raster cell values (optimization fix for...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/getValuesBlock_stackfix.R

Description

A faster version of getValuesBlock for RasterStack.

Usage

1
2
getValuesBlock_stackfix(x, row = 1, nrows = 1, col = 1, ncols = (ncol(x)
  - col + 1), lyrs = (1:nlayers(x)))

Arguments

x

Raster* object

row

positive integer. Row number to start from, should be between 1 and nrow(x)

nrows

postive integer. How many rows? Default is 1

col

postive integer. Column number to start from, should be between 1 and ncol(x)

ncols

postive 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))

Details

In certain cases, getValuesBlock may run very slowly on a RasterStack, particularly when the RasterStack is comprised of RasterBricks. This code attempts to fix the inefficiency by running the extract on each unique file of the RasterStack, rather than each unique layer.

Value

matrix or vector (if (x=RasterLayer), unless format='matrix')

Author(s)

Jonathan A. Greenberg

See Also

getValuesBlock

Examples

1
2
3
4
5
6
tahoe_highrez <- brick(system.file("external/tahoe_highrez.tif", package="spatial.tools"))
tahoe_highrez_stack <- stack(tahoe_highrez,tahoe_highrez,tahoe_highrez)
# getValuesBlock stack extraction:
system.time(tahoe_highrez_extract <- getValuesBlock(tahoe_highrez_stack))
# getValuesBlock_stackfix stack extraction:
system.time(tahoe_highrez_extract <- getValuesBlock_stackfix(tahoe_highrez_stack))

azvoleff/spatial.tools documentation built on June 4, 2017, 12:08 a.m.