reaggregate_by_function: Re-aggregate raster layers according to function

Description Usage Arguments Details Value Examples

View source: R/reaggregate_by_function.R

Description

This function re-aggregates a multilayered raster dataset according to a function (e.g. maximum, minimum, mean) and a time interval. All raster outputs will be written to GeoTIFF files.

Usage

1
2
reaggregate_by_function(data_layers, fun, dates, basename, output_directory,
  bylayer = FALSE, clean = FALSE, mc.cores = 1)

Arguments

data_layers

A RasterStack or RasterBrick object containing the MODIS data. A RasterBrick object is preferable to reduce processing time.

fun

A function that returns a single value and has an na.rm argument, which will be set to TRUE. Examples are mean, sum, max, median, and min.

dates

A vector of class Date or a number. If dates is a date vector, the data will be re-aggregated to monthly data by fun. If dates is a number, the data will be re-aggregated in groups specified by the number. For example, if dates=4 the data will be reaggregated by grouping layers in groups of 4 and executing fun.

basename

A character that will be prepended to all file names to be written.

output_directory

A character file path to a directory where all files will be written.

bylayer

A logical indicating if the individual raster outputs should remain separate (TRUE) or combined into a single multilayered raster file (FALSE).

clean

A logical indicating if the individual raster outputs should be deleted once the multilayered raster has been created. Ignored if bylayer=TRUE.

mc.cores

A numeric indicating the number of cores to be used in parallel computing.

Details

Note that writing to a single multilayered raster means that layer names will not be preserved. That is to say, all layers will simply be named according to the file name with a numerical index appended when the multilayered GeoTIFF is read back into R. The drawback is that any date information contained in the layer name will be lost. Thus, it is advisable to keep the individual raster files so that one can reference back to the date information.

Value

Nothing. This function has a side-effect of writing files to a directory.

Examples

1
2
3
4
## Not run: 
reaggregate_by_function(data_layers, max, "MODIS_max", "C:/Desktop", mc.cores=6)

## End(Not run)

jnghiem/bfasttools documentation built on Nov. 4, 2019, 3:02 p.m.