Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/getValuesBlock_stackfix.R
A faster version of getValuesBlock for RasterStack.
1 2 | getValuesBlock_stackfix(x, row = 1, nrows = 1, col = 1,
ncols = (ncol(x) - col + 1), lyrs = (1:nlayers(x)))
|
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)) |
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.
matrix or vector (if (x=RasterLayer), unless format='matrix')
Jonathan A. Greenberg
1 2 3 4 5 6 7 | library("raster")
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.