resampleStack: Function: Resample a RasterStack object

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

Description

'ResampleStack' transfers values between non matching 'RasterLayers' in terms of origin and spatial resolution. To adjust the spatial resolution, a bilinear interpolation is applied.

Usage

1
2
3
4
resampleStack(rasterStack, resampleSettings, decimalPlaces = 4,
    outType = "mean", writeOutput = FALSE,
    outputName = "resample", tmpCreate = FALSE, tmpDir = "",
    outDir = "", ... )

Arguments

rasterStack

A 'RasterStack' object to be resampled.

resampleSettings

A 'RasterLayer' object with the settings that 'RasterStack' should be resampled to.

decimalPlaces

An object of class 'numeric'. Number of decimal places (default = 4).

outType

An object of class 'character'. Type of output to be returned by the function: "mean" (default) or "sum".

writeOutput

An object of class 'logical'. Determines whether the ouput shall be exported as RasterLayer (TRUE) or not (FALSE, default).

outputName

An object of class 'character'. File name for the output RasterLayer(s) (default = "dcIceMelt").

tmpCreate

An object of class 'logical'. Determines whether a temporary directory should be used (TRUE) or not (FALSE, default). Recommendend if large datasets are processed.

tmpDir

An object of class 'character'. Directory where processing files can be temporarily stored if 'tmpCreate' = TRUE.

outDir

An object of class 'character'. Directory for the output files if 'writeOutput' = TRUE.

...

Further arguments passed to the function unitConv, which is implemented in resampleStack. For more information see section details.

Details

In addition to the function resample, 'resampleStack' provides the export of each resampled 'RasterLayer' as GeoTIFF.

If it is desired to convert the unit ('u1') of the 'RasterStack' into a different unit ('u2'), the arguments ('u1') and ('u2') (see unitConv) can be additionally passed to 'rasterStack'.

Value

An object of class 'RasterLayer' returning the mean or sum (depending on outType) of the resampled 'RasterStack'.

Note

File format of written ouput: GeoTIFF.

Author(s)

Alexander R. Groos (alexander.groos@giub.unibe.ch)

See Also

resample, unitConv

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Load the provided RasterLayer objects as exemplary
# input for the function
data(airTemperature_30m_daily, precip_10km_daily,
    package = "glacierSMBM")
# Individual RasterLayer objects should be loaded or created
# using the function raster()

# Resample and interpolate a precipitation file with 10 km spatial
# resolution using the parameters of air temperature (30m)
# Additionally, convert from mm h-1 to m d-1
output <- resampleStack(stack(precip_10km_daily),
    airTemperature_30m_daily,1, writeOutput = FALSE,
    u1 = "mm/h", u2 = "mm/d", decimalPlaces = 5)

# Plot output
plot(precip_10km_daily, main = "precipitation (10km)",
    legend.args=list(text='precipitation (m)', side=3, line=1.5))
plot(output, main = "resampled precipitation (30m)",
    legend.args=list(text='precipitation (m)', side=3, line=1.5))

Example output

Loading required package: raster
Loading required package: sp
Loading required package: udunits2
udunits system database read
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied

glacierSMBM documentation built on May 2, 2019, 3:42 a.m.