gdal_sd: Cell-wise raster standard deviation

Description Usage Arguments Details Value Examples

Description

Calculate a raster layer whose cells' values are the standard deviations across the bands of a single raster, or across multiple rasters.

Usage

1
gdal_sd(infile, outfile, return_raster = TRUE, quiet = TRUE)

Arguments

infile

A RasterStack or RasterBrick, a file path to a single, multiband raster file, or a vector of paths to multiple raster files. If a vector of paths is provided, then if any of the rasters have multiple bands, the first band will be used. A maximum of 26 bands or files can be provided to infile.

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 is TRUE, a temporary output file will be created.

return_raster

Logical. Should the output raster be read back in to R as a Raster object?

quiet

Logical. Should GDAL output messages be suppressed?

Details

The quantity calculated is the corrected sample standard deviation, calculated as sqrt(sum((x - mean(x))^2)/(length(x)-1)).

Value

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.

Examples

 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)

johnbaums/things documentation built on May 19, 2019, 3:03 p.m.