Description Usage Arguments Details Value Examples
Calculate a raster layer whose cells' values are the standard deviations across the bands of a single raster, or across multiple rasters.
1 |
infile |
A |
outfile |
A path to the desired output raster file, which will be
created if it doesn't already exist (though the containing directory must
exist). If not provided and |
return_raster |
Logical. Should the output raster be read back in to R
as a |
quiet |
Logical. Should GDAL output messages be suppressed? |
The quantity calculated is the corrected sample standard deviation, calculated as sqrt(sum((x - mean(x))^2)/(length(x)-1)).
Unless return_raster
is TRUE
, gdal_sd
creates
the file specified at outfile
but returns NULL
, invisibly, to
R. If return_raster
is TRUE
, the standard deviation
Raster
object is returned to R.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | library(raster)
s <- stack(replicate(5, raster(matrix(rnorm(100), ncol=10))))
# Input is a RasterStack
gdal_sd(s)
# Input is multiple raster files
writeRaster(s, ff <- paste0(tempfile(), 1:5, '.tif'), bylayer=TRUE)
gdal_sd(ff)
# Input is a raster file with multiple bands
writeRaster(s, f <- tempfile(fileext='.tif'))
gdal_sd(f)
# Input is a RasterBrick with multiple bands
b <- brick(f)
gdal_sd(b)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.