Learn R Programming

envirem (version 2.3)

generateRasters: Execute Layer Creation

Description

Main function to generate specified ENVIREM layers. If requested, this function will split input rasters into tiles, generate desired variables, and reassemble the results. For the distinction between this function and layerCreation, see Details.

Usage

generateRasters(
  var,
  maindir,
  prefix = "",
  outputDir = "./",
  rasterExt = ".tif",
  nTiles = 1,
  tempScale = 1,
  precipScale = 1,
  overwriteResults = TRUE,
  outputFormat = "GTiff",
  tempDir = "~/temp",
  gdalinfoPath = NULL,
  gdal_translatePath = NULL,
  useCompression = TRUE
)

Value

The requested set of rasterLayers will be written to outputDir.

Arguments

var

a vector of variable names to generate, see Details.

maindir

path to directory of input rasters

prefix

prefix to append to output filename

outputDir

output directory.

rasterExt

the file extension of the input rasters

nTiles

the number of tiles to split the rasters when tiling is requested, must be a perfect square

tempScale

integer; scaling factor for the temperature data, see envirem for additional details.

precipScale

integer; scaling factor for the precipitation data, see envirem for additional details.

overwriteResults

logical, should existing rasters be overwritten

outputFormat

output format for rasters, see writeRaster for options

tempDir

temporary directory for raster tiles that will be created and then removed

gdalinfoPath

path to gdalinfo binary, leave as NULL if it is in the default search path.

gdal_translatePath

path to gdal_translate binary, leave as NULL if it is in the default search path.

useCompression

logical; should compression options be used to achieve smaller file sizes. Only pertains to format GTiff.

Author

Pascal Title

Details

The function layerCreation will generate envirem rasters from input R objects (rasterStacks) and will return the result as an R object. In contrast, the function generateRasters reads in input rasters from a specified directory, splits input rasters into tiles if necessary, internally calls layerCreation and writes the result to file.

Possible variables to generate include:

annualPET
aridityIndexThornthwaite
climaticMoistureIndex
continentality
embergerQ
growingDegDays0
growingDegDays5
maxTempColdest
minTempWarmest
meanTempColdest
meanTempWarmest
monthCountByTemp10
PETColdestQuarter
PETDriestQuarter
PETseasonality
PETWarmestQuarter
PETWettestQuarter
thermicityIndex

If var = 'all', then all of the variables will be generated.

Rasters in mainDir should be named appropriately (see verifyFileStructure) and with identical resolution, origin and extent.

Output rasters are written with the most appropriate dataType, as inferred with dataTypeCheck. This will reduce the file size of these rasters.

If the goal is to use these rasters with the standalone Maxent program, we recommend outputFormat = 'EHdr'.

IMPORTANT: Temporary files can quickly fill up your hard drive when working with large rasters. There are two temporary directories to consider for this function: The tempDir directory defined as an argument in this function is used for storing intermediate files when splitting rasters into tiles (and is ignored if nTiles = 1). The raster package will use another directory for storing temporary rasters. This can be can be viewed with rasterOptions(), and can be set with rasterOptions(tmpdir = 'path-to-dir'). Be sure that this is pointing to a directory with plenty of available space. Both temporary directories are automatically cleared.

See Also

Naming of rasters in inputDir will be checked with verifyFileStructure.